Sh@dow
November 3rd, 2009, 08:10 AM
Hi all.
I'm trying to create dialog box using pure API in VS2005.First i'm creating window and then dialog box.The problem is that dialog box is not shown correctly.I can see only buttos which are in the dialog box,the dialog box frame and system menu(close,minimie) are not shown.It looks like:
http://img27.imageshack.us/img27/7273/dbbug.jpg
Where can be the problem?The same source in VS6 works fine.I tried to play aroud with option in the resource editor but still no result.
The code is as folows:
#include <windows.h>
#include "resource.h"
LRESULT CALLBACK wndproc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam );
BOOL CALLBACK dproc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASSEX wnd;
wnd.cbSize=sizeof(wnd);
wnd.style=CS_HREDRAW|CS_VREDRAW;
wnd.lpfnWndProc=wndproc;
wnd.cbClsExtra=0;
wnd.cbWndExtra=0;
wnd.hInstance=0;
wnd.hIcon=0;//LoadIcon(gInstance,MAKEINTRESOURCE(668));;
wnd.hCursor=LoadCursor(NULL,IDC_ARROW);
wnd.hbrBackground=(HBRUSH)13;
wnd.lpszMenuName=MAKEINTRESOURCE(5000);
wnd.lpszClassName=L"class";
wnd.hIconSm=NULL;
RegisterClassEx(&wnd);
HWND handle=CreateWindowEx(NULL,L"class",L"test",WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_MAXIMIZE,
0,0,790,550,NULL,NULL,
NULL,NULL);
ShowWindow(handle,SW_SHOW);
UpdateWindow(handle);
MSG message;
while(GetMessage(&message,0,0,0))
{
TranslateMessage(&message);
DispatchMessage(&message);
}
return 0;
}
LRESULT CALLBACK wndproc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam )
{
switch(uMsg)
{
case WM_CREATE:
{
}
break;
case WM_COMMAND:
{
if(wParam == 140)
{
DialogBox(0,MAKEINTRESOURCE(IDD_DIALOG1),hwnd,dproc);
}
}
break;
case WM_CLOSE:
{
ExitProcess(0);
}
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
BOOL CALLBACK dproc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
{
return 1;
}
break;
return 0;
}
}
I'm trying to create dialog box using pure API in VS2005.First i'm creating window and then dialog box.The problem is that dialog box is not shown correctly.I can see only buttos which are in the dialog box,the dialog box frame and system menu(close,minimie) are not shown.It looks like:
http://img27.imageshack.us/img27/7273/dbbug.jpg
Where can be the problem?The same source in VS6 works fine.I tried to play aroud with option in the resource editor but still no result.
The code is as folows:
#include <windows.h>
#include "resource.h"
LRESULT CALLBACK wndproc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam );
BOOL CALLBACK dproc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASSEX wnd;
wnd.cbSize=sizeof(wnd);
wnd.style=CS_HREDRAW|CS_VREDRAW;
wnd.lpfnWndProc=wndproc;
wnd.cbClsExtra=0;
wnd.cbWndExtra=0;
wnd.hInstance=0;
wnd.hIcon=0;//LoadIcon(gInstance,MAKEINTRESOURCE(668));;
wnd.hCursor=LoadCursor(NULL,IDC_ARROW);
wnd.hbrBackground=(HBRUSH)13;
wnd.lpszMenuName=MAKEINTRESOURCE(5000);
wnd.lpszClassName=L"class";
wnd.hIconSm=NULL;
RegisterClassEx(&wnd);
HWND handle=CreateWindowEx(NULL,L"class",L"test",WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_MAXIMIZE,
0,0,790,550,NULL,NULL,
NULL,NULL);
ShowWindow(handle,SW_SHOW);
UpdateWindow(handle);
MSG message;
while(GetMessage(&message,0,0,0))
{
TranslateMessage(&message);
DispatchMessage(&message);
}
return 0;
}
LRESULT CALLBACK wndproc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam )
{
switch(uMsg)
{
case WM_CREATE:
{
}
break;
case WM_COMMAND:
{
if(wParam == 140)
{
DialogBox(0,MAKEINTRESOURCE(IDD_DIALOG1),hwnd,dproc);
}
}
break;
case WM_CLOSE:
{
ExitProcess(0);
}
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
BOOL CALLBACK dproc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
{
return 1;
}
break;
return 0;
}
}