為什麼顯示文字只要一移動視窗捲軸文字就會消失 |
缺席
|
forverlove5202
一般會員 發表:5 回覆:10 積分:3 註冊:2008-03-04 發送簡訊給我 |
|
ikk
尊榮會員 發表:4 回覆:413 積分:768 註冊:2003-06-30 發送簡訊給我 |
|
forverlove5202
一般會員 發表:5 回覆:10 積分:3 註冊:2008-03-04 發送簡訊給我 |
|
ikk
尊榮會員 發表:4 回覆:413 積分:768 註冊:2003-06-30 發送簡訊給我 |
|
forverlove5202
一般會員 發表:5 回覆:10 積分:3 註冊:2008-03-04 發送簡訊給我 |
===================引 用 ikk 文 章=================== 在Form上放個label 應該就不會消失了吧? 你是用Canvas 寫字上去嗎? 我現在用ListView來顯示可是又遇到了一個問題 我想要當我按下ok時才跑出全部並不是一開始就建立..不知怎麼改 #include #include #include #include "Dawson002.h" TCHAR szEditOne[81]; HINSTANCE hInst; BOOL CALLBACK TestDlgProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: SetDlgItemText(hDlg,IDC_EDIT1,szEditOne); return(TRUE); case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: GetDlgItemText(hDlg,IDC_EDIT1,szEditOne,sizeof(szEditOne)-1); EndDialog(hDlg,TRUE); return(TRUE); case IDCANCEL: EndDialog(hDlg,FALSE); return(TRUE); } break; default: return(FALSE); } return(TRUE); } LRESULT CALLBACK WndProc(HWND hWnd,UINT iMsg,WPARAM wParam,LPARAM lParam) { struct AREC{ char name[20]; char date[20]; int size; }; FILE *inptr; struct AREC ary[100]; PAINTSTRUCT ps; static HWND hList = NULL; HDC hDC; static HANDLE hFile; TCHAR szBuf[1024]; int i=0; LVITEM item; switch (iMsg) { case WM_CREATE: hList = CreateWindowEx(WS_EX_CLIENTEDGE,WC_LISTVIEW,"", WS_CHILD | LVS_REPORT | WS_VISIBLE, 0,0,0,0,hWnd,(HMENU)101,hInst,NULL); if (hList) { LV_COLUMN col; col.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; col.fmt = LVCFMT_LEFT; col.cx = 160; col.pszText = "檔案名稱"; col.iSubItem = 0; ListView_InsertColumn(hList,0,&col); col.cx = 160; col.pszText = "檔案日期"; col.iSubItem = 1; ListView_InsertColumn(hList,1,&col); col.cx = 160; col.pszText = "檔案大小"; col.iSubItem = 2; ListView_InsertColumn(hList,2,&col); } return(0); case WM_SIZE: if (wParam != SIZE_MINIMIZED) MoveWindow(hList,0,0,LOWORD(lParam),HIWORD(lParam),TRUE); return(0); case WM_PAINT: hDC = BeginPaint(hWnd,&ps); EndPaint(hWnd,&ps); return(0); case WM_COMMAND: switch (LOWORD(wParam)) { case IDM_Demo: /*建立及開啟Modal對話盒*/ DialogBoxParam(0,"TestDialog",hWnd,(DLGPROC)TestDlgProc,0); ListView_DeleteAllItems(hList); hDC = GetDC(hWnd); if(szEditOne[1]!='\0') { inptr=fopen(szEditOne,"r"); while (fscanf(inptr,"%s %s %d",&ary[i].name,&ary[i].date,&ary[i].size)!=EOF) { item.mask=LVIF_TEXT; item.iItem=i; item.iSubItem=0; item.pszText=szBuf; wsprintf(szBuf,"%s",ary[i].name); ListView_InsertItem(hList,&item); wsprintf(szBuf,"%s",ary[i].date); item.iSubItem=1; ListView_SetItem(hList,&item); wsprintf(szBuf,"%d",ary[i].size); item.iSubItem=2; ListView_SetItem(hList,&item); i ; } fclose(inptr); } ReleaseDC(hWnd,hDC); return(0); case IDM_Exit: DestroyWindow(hWnd); return(0); case IDM_Amply: ListView_DeleteAllItems(hList); hDC = GetDC(hWnd); if(szEditOne[1]!='\0') { inptr=fopen(szEditOne,"r"); while (fscanf(inptr,"%s %s %d",&ary[i].name,&ary[i].date,&ary[i].size)!=EOF) { item.mask=LVIF_TEXT; item.iItem=i; item.iSubItem=0; item.pszText=szBuf; wsprintf(szBuf,"%s",ary[i].name); ListView_InsertItem(hList,&item); wsprintf(szBuf,"%s",ary[i].date); item.iSubItem=1; ListView_SetItem(hList,&item); i ; } fclose(inptr); } ReleaseDC(hWnd,hDC); } break; case WM_DESTROY: PostQuitMessage(0); return(0); } return(DefWindowProc(hWnd,iMsg,wParam,lParam)); } int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow) { static TCHAR szAppName[] = "MyApp"; HWND hWnd; MSG msg; WNDCLASSEX wndclass; wndclass.cbSize = sizeof(wndclass); wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION); wndclass.hCursor = LoadCursor(NULL,IDC_ARROW); wndclass.hbrBackground =(HBRUSH)(COLOR_WINDOW 1); wndclass.lpszMenuName = "IDR_MENU1"; wndclass.lpszClassName = szAppName; wndclass.hIconSm = LoadIcon(NULL,IDI_APPLICATION); RegisterClassEx(&wndclass); hInst = hInstance; InitCommonControls(); hWnd = CreateWindow(szAppName,"函式示範:FindFirstFile",WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT, NULL,NULL,hInstance,NULL); ShowWindow(hWnd,iCmdShow); UpdateWindow(hWnd); while (GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return(msg.wParam); } |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |