#include <windows.h>
#include <stdio.h>
#include <commdlg.h>
LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
MSG msg;
HWND hwnd;
WNDCLASSEX wnd;
static char szAppName[] = "HelloWin" ;
wnd.cbSize = sizeof(WNDCLASSEX );
wnd.style = CS_HREDRAW | CS_VREDRAW;
wnd.lpfnWndProc = WndProc;
wnd.cbClsExtra = 0;
wnd.cbWndExtra = 0;
wnd.hInstance = hInstance;
wnd.hIcon = NULL;
wnd.hCursor=LoadCursor(NULL, IDC_ARROW );
wnd.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE +1;
wnd.lpszMenuName = NULL;
wnd.lpszClassName = szAppName;
wnd.hIconSm = NULL;
RegisterClassEx(&wnd);
hwnd=CreateWindow(szAppName,"Write_File", WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,50,50,200,200,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,iCmdShow);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
//--------------------------------------------------
LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_CREATE :
{
CreateWindow( "BUTTON","Îòêðûòü",WS_CHILD | WS_VISIBLE, 10,10,80,20,hwnd,(HMENU)1,NULL,NULL);
return 0 ;
}
case WM_COMMAND:
{
switch(wParam)
{
case 1:
{
OPENFILENAME ofn; // ñòðóêòóðà ñòàíäàðòíîãî äèàëîãîâîãî îêíà
char szFile[260]; // áóôåð äëÿ èìåíè ôàéëà
HANDLE hf; // äåñêðèïòîð ôàéëà
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileName(&ofn)==TRUE)
hf = CreateFile(ofn.lpstrFile, GENERIC_READ,
0, (LPSECURITY_ATTRIBUTES) NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
(HANDLE) NULL);
return 0;
}
return 0;
}
return 0;
}
case WM_DESTROY :
{
PostQuitMessage (0) ;
return 0 ;
}
}
return DefWindowProc (hwnd, msg, wParam, lParam) ;
}
Не создается стандартное диалоговое окно???
Написал программу
Компилится нормально, никаких ошибок но при выполнении диалоговое окно не создается.
В чем дело????
Может кто подскажет ошибку.
текст программы
Код:
char szPath[MAX_PATH] = {0};:p