int SCREW_constructor ( int dialog_id,: {; g$ p( z# l7 o
void * client_data,, I, \2 b8 c1 j) C' F, B
UF_STYLER_item_value_type_p_t callback_data)
* Q6 u- d( S6 N{
$ l; \8 \$ g9 S ~' E2 F% k if ( UF_initialize() != 0)
" b' _( U/ N8 Z. |# e. g) v' X: A1 \ return ( UF_UI_CB_CONTINUE_DIALOG );
5 p; i% O$ I& t$ D3 F UF_STYLER_item_value_type_t data;* l m5 G9 c6 `; p) j& {
char *names[ SCREW_OPTION_CHOICE_COUNT ]; 2 q V7 x' m# t& ^- G
try! F8 k6 u+ x" h9 B, G
{+ V* V& M" a s$ v g9 l2 w5 \
CDatabase database;
9 W; o1 G$ R8 W' T. O! y9 v database.OpenEx( _T("DSN=screw"), CDatabase::noOdbcDialog);
6 |( R6 {/ R6 @& x$ \8 \! ^: r; a1 R Clzh ScrewSet;: c2 R; e; F: w) |1 g: ^, A- j; E. U
ScrewSet.Open( CRecordset::snapshot, "select * from lzh" );
, q- W' r% k6 J0 v; q7 l+ W int i = 0;/ I' k6 W7 p: Y$ a! N* p2 s- Q
do5 m- X+ v0 F3 s6 |
{' K! U/ g5 q) C+ ~7 o
if( ScrewSet.IsEOF( ) ) break;
& l* S+ l. ]/ a+ K3 A strcpy( names[ i++ ] = (char*)malloc( sizeof( char ) * 30 ), ScrewSet.m_SP );; M& d/ m: v+ u: j; C, F1 y4 V
( Z- L( m: @7 [ p% p: p
ScrewSet.MoveNext( );
% C/ @- }" H! ]& {5 V8 E+ X" S1 A }while( 1 );
9 b$ e* `( I2 J; a database.Close( ); i. g( K4 i- F# t
data.item_id = SCREW_OPTION_CHOICE;3 {- z# C5 B+ A0 z- |7 M! F
data.item_attr = UF_STYLER_SUBITEM_VALUES;9 a. E4 ?, Y1 e
data.count = SCREW_OPTION_CHOICE_COUNT;
- R9 N2 G1 `5 a& n' m data.value.strings = names;
: H; M# x$ I& L6 z% m0 E UF_STYLER_set_value( dialog_id, &data );
5 J/ J' q2 {# Z! e) S data.item_attr = UF_STYLER_VALUE;* v1 D4 e" H3 T
data.value.integer = 0;
- Y6 _/ @0 m+ W6 i2 E' h2 r" z! k- O UF_STYLER_set_value( dialog_id, &data );
8 O. ~# f! `" ~2 H3 i. b for ( i = 0; i < SCREW_OPTION_CHOICE_COUNT; i++ )4 H! ~1 D: u. v
{* W! v! N! J8 z; M" }' c) R3 ~+ B
free( names[ i ] );
( _4 G) P1 ^9 F* B }
, h9 s1 f+ J8 P; w8 a }& J2 g/ N- @- T8 ]; n+ R
catch( CDBException *pe )
% r& {; K" ]2 d4 a- F& O A+ C6 H {
6 @5 J+ u k- K. L) A/ L AfxMessageBox( "Exception!" );4 r9 K# [$ K& H0 n* d# X2 n' {" ?
AfxMessageBox( pe->m_strError );) f' G$ v, l! x2 r8 V; h
pe -> Delete( );
: r. m+ s0 e( M }4 @/ e U- w* ~& ?9 D: m
UF_terminate();) r( N [# b x: |+ U; k
return ( UF_UI_CB_CONTINUE_DIALOG );
/ ?8 g, h4 Z( k, O% Q3 L4 f% k+ N}
8 _! Z) s: A$ q' \这运行之后错误是:strcpy(names[i++]=(char*)malloc(sizeof(char)*4),ScrewSet.m_SP);
8 e) O4 M. w/ h9 H" H& P谢谢各位了。 |