rambo0808 于 2007-08-28 09:23:20发表:
朋友们提点建议啊
rambo0808 于 2007-08-26 22:02:12发表:
[code] 完整的代码有近 2000行 我就把这个这个控件部分的代码发上来 大家帮我分析一下吧 这个控件在另外一个窗口中,以InitDialogBox5(hwnd)来触发 /*------------------------------------------------------------ control 5 ------------------------------------------------------------*/ static DLGTEMPLATE MyDlg5 = { WS_VISIBLE | WS_BORDER | WS_CAPTION, WS_EX_NONE, 250, 200, 300 ,200, "保存文件", 0, 0, 4, NULL, 0 }; static CTRLDATA CtrlInitData5 [] = { { "static", WS_VISIBLE | SS_LEFT, 20, 50, 100 ,20, ID_DISP5, "输入文件名:", 0, WS_EX_NONE }, { "edit", WS_VISIBLE | WS_BORDER | SS_SIMPLE| ES_LOWERCASE , 110, 50, 150 ,20, ID_EDIT5, "", 0, WS_EX_NONE }, { "button", WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON , 80, 120, 50,25, ID_OK5, "确定", 0, WS_EX_NONE, }, { "button", WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON , 170, 120, 50 ,25, ID_CANCEL5, "取消", 0, WS_EX_NONE, } }; static int MyDlgProc5(HWND hDlg5, int message, WPARAM wParam, LPARAM lParam) { HDC hdc; static char savename1[20]; static char savename2[20] = "/tmp/"; static char savename3[5] = ".bmp"; static int i,j,m,n; static RECT rc = {0,88,612,512}; switch (message) { case MSG_INITDIALOG: return 1; case MSG_COMMAND: switch (LOWORD(wParam)) { case ID_OK5: GetWindowText(GetDlgItem(hDlg5, ID_EDIT5), savename1, 20); for(i = 5, j = 0; j<10; i++, j++) { savename2[i] = savename1[j] ;} printf("savename2's length:%d\n",strlen(savename2)); m = strlen(savename2); for(i = m,j=0 ;j<4; i++, j++) { savename2[i] = savename3[j];} printf("savename:%s\n",savename2); if(fork() == 0) { if(execl"/bin/cp", "cp","/home/example/myexample/bmpdisp512/00.jpg",savename2, NULL) < 0 ) perror("execl error!"); printf("this is a test\n"); exit(0); } DestroyAllControls(hDlg5); EndDialog(hDlg5, wParam); // InvalidateRect (hWnd1, &rc, FALSE); break; case ID_CANCEL5: DestroyAllControls(hDlg5); EndDialog(hDlg5, wParam); break; default: break; } break; case MSG_CLOSE: DestroyAllControls(hDlg5); EndDialog(hDlg5, wParam); PostQuitMessage (hDlg5); break; default: return DefaultDialogProc(hDlg5, message, wParam, lParam); } return 0; } static void InitDialogBox5(HWND hDlg2) { MyDlg5.controls = CtrlInitData5; DialogBoxIndirectParam(&MyDlg5, hDlg2, MyDlgProc5, 0L); } [/code]
rambo0808 于 2007-08-25 21:45:18发表:
图片3图片3
rambo0808 于 2007-08-25 21:44:42发表:
图片2图片2
rambo0808 于 2007-08-28 09:23:20发表:
朋友们提点建议啊
rambo0808 于 2007-08-26 22:02:12发表:
[code]
完整的代码有近 2000行
我就把这个这个控件部分的代码发上来
大家帮我分析一下吧
这个控件在另外一个窗口中,以InitDialogBox5(hwnd)来触发
/*------------------------------------------------------------
control 5
------------------------------------------------------------*/
static DLGTEMPLATE MyDlg5 =
{ WS_VISIBLE | WS_BORDER | WS_CAPTION,
WS_EX_NONE,
250, 200, 300 ,200,
"保存文件",
0, 0,
4,
NULL,
0
};
static CTRLDATA CtrlInitData5 [] =
{
{ "static",
WS_VISIBLE | SS_LEFT,
20, 50, 100 ,20,
ID_DISP5,
"输入文件名:",
0,
WS_EX_NONE
},
{ "edit",
WS_VISIBLE | WS_BORDER | SS_SIMPLE| ES_LOWERCASE ,
110, 50, 150 ,20,
ID_EDIT5,
"",
0,
WS_EX_NONE
},
{ "button",
WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON ,
80, 120, 50,25,
ID_OK5,
"确定",
0,
WS_EX_NONE,
},
{ "button",
WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON ,
170, 120, 50 ,25,
ID_CANCEL5,
"取消",
0,
WS_EX_NONE,
}
};
static int MyDlgProc5(HWND hDlg5, int message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
static char savename1[20];
static char savename2[20] = "/tmp/";
static char savename3[5] = ".bmp";
static int i,j,m,n;
static RECT rc = {0,88,612,512};
switch (message)
{
case MSG_INITDIALOG:
return 1;
case MSG_COMMAND:
switch (LOWORD(wParam))
{
case ID_OK5:
GetWindowText(GetDlgItem(hDlg5, ID_EDIT5), savename1, 20);
for(i = 5, j = 0; j<10; i++, j++)
{ savename2[i] = savename1[j] ;}
printf("savename2's length:%d\n",strlen(savename2));
m = strlen(savename2);
for(i = m,j=0 ;j<4; i++, j++)
{ savename2[i] = savename3[j];}
printf("savename:%s\n",savename2);
if(fork() == 0)
{ if(execl"/bin/cp", "cp","/home/example/myexample/bmpdisp512/00.jpg",savename2, NULL) < 0 )
perror("execl error!");
printf("this is a test\n");
exit(0);
}
DestroyAllControls(hDlg5);
EndDialog(hDlg5, wParam);
// InvalidateRect (hWnd1, &rc, FALSE);
break;
case ID_CANCEL5:
DestroyAllControls(hDlg5);
EndDialog(hDlg5, wParam);
break;
default:
break;
}
break;
case MSG_CLOSE:
DestroyAllControls(hDlg5);
EndDialog(hDlg5, wParam);
PostQuitMessage (hDlg5);
break;
default:
return DefaultDialogProc(hDlg5, message, wParam, lParam);
}
return 0;
}
static void InitDialogBox5(HWND hDlg2)
{ MyDlg5.controls = CtrlInitData5;
DialogBoxIndirectParam(&MyDlg5, hDlg2, MyDlgProc5, 0L);
}
[/code]
rambo0808 于 2007-08-25 21:45:18发表:
图片3图片3
rambo0808 于 2007-08-25 21:44:42发表:
图片2图片2