int SCREW_constructor ( int dialog_id,! ]; ~: t1 {* N* Q V" ^- H
void * client_data,
' Z `; G* \2 A7 b UF_STYLER_item_value_type_p_t callback_data)
4 t: U* I' P& O# a$ v{
1 h7 N3 ~+ Y: ?: s& s- T' P if ( UF_initialize() != 0) 8 K+ B+ I5 b$ P$ M
return ( UF_UI_CB_CONTINUE_DIALOG );) ~! h# [5 ?/ a& M' H# a
UF_STYLER_item_value_type_t data;
w* D- F% F9 B( G$ D, J! I char *names[ SCREW_OPTION_CHOICE_COUNT ]; 8 v: w1 b. }' O9 U
try
' a1 Q* G0 y+ _) s8 }2 A0 g" Q {' W8 ]8 K* R2 Z- e
CDatabase database;# C9 Q3 ^/ @( T5 D
database.OpenEx( _T("DSN=screw"), CDatabase::noOdbcDialog);# ]' `0 c$ r8 w/ _, I: w4 H
Clzh ScrewSet;" S7 Y/ m, o* R
ScrewSet.Open( CRecordset::snapshot, "select * from lzh" );! J. f9 l: ]# h7 X/ d9 B s( O
int i = 0;' F1 p8 x+ a0 t% n/ I0 K% Q
do
6 t$ p4 K1 H' L* D5 v5 E* G1 [5 ` { F0 h F5 |( \! L2 L
if( ScrewSet.IsEOF( ) ) break;; Y3 X! o w, Q6 b$ H7 u. e$ T, d
strcpy( names[ i++ ] = (char*)malloc( sizeof( char ) * 30 ), ScrewSet.m_SP );
+ V7 z0 w; ~; c/ b2 F
1 U! {# o; j( f8 h ScrewSet.MoveNext( );
7 B Z+ e: L, I: r: y7 L: E }while( 1 );7 W* R' d3 G, j5 R7 j) A( O* w# d
database.Close( );
7 V- ~5 D: l, t0 }/ n2 n% H data.item_id = SCREW_OPTION_CHOICE;' H8 F9 m9 i; g: s1 R8 `
data.item_attr = UF_STYLER_SUBITEM_VALUES;
2 {9 I! ?+ G4 y: R data.count = SCREW_OPTION_CHOICE_COUNT;
9 _: e. e# w- T9 d3 R- Q data.value.strings = names;
' @& c4 K' |& ^+ O# W2 i6 E UF_STYLER_set_value( dialog_id, &data );
' C; \( W4 p( h) N. @- [( w' ^ data.item_attr = UF_STYLER_VALUE;! m8 K$ f4 v7 X. W) q# V
data.value.integer = 0;
7 Q% {/ d. ?* H/ t/ V UF_STYLER_set_value( dialog_id, &data );
, r4 S/ L) v" x4 J9 `0 G# N for ( i = 0; i < SCREW_OPTION_CHOICE_COUNT; i++ ): s3 @7 e3 M& X7 ]
{, T3 H1 [: y- c# ^, P
free( names[ i ] );
4 L3 Y7 k) u j0 _5 I }
$ h+ T2 L6 t5 t# d }# {& d% M/ u' j* D5 t
catch( CDBException *pe )
) m" U' t8 @4 N1 P" G2 ? {' k7 b4 f ?. m0 L. i
AfxMessageBox( "Exception!" );
' D* ?# v' R: S. l- |3 G' W) W9 R AfxMessageBox( pe->m_strError );. S; S* K, V: A2 r9 v. x& a( s
pe -> Delete( );
( K8 Y7 l" q, c' l0 V% W }
8 ~: w" s8 K! q3 X* w UF_terminate();3 F6 V3 f$ O/ K% e* e' L
return ( UF_UI_CB_CONTINUE_DIALOG );! G1 F! n& t( F2 X4 }, h
}
# E1 j* U$ v1 q6 Q这运行之后错误是:strcpy(names[i++]=(char*)malloc(sizeof(char)*4),ScrewSet.m_SP);5 X: j" H; x) f4 V7 G: `
谢谢各位了。 |