为什么我在dll中创建的非模态对话框,并创建的消息循环进入了“死循环”;但是不写消息循环能实现点击界面吗?(附代码)被经理批评了,求求了啊55555555
#include "stdafx.h"
#include <windows.h>
#include"resource.h"
#include "stdafx.h"
#include <commctrl.h>
#include <aygshell.h>
#include <sipapi.h>
#include <commdlg.h>
#include <gx.h>
#include <pm.h>
#include <pimstore.h>
#include <windowsx.h>
#include <connmgr.h>
#include <ras.h>
#include <connmgr_proxy.h>
#include <cfgmgrapi.h> //shiqw add
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
BOOL CALLBACK DlgProc (HWND, UINT, WPARAM, LPARAM) ;
extern"C" int __declspec(dllexport) ShowDialog(HWND mhwnd,HINSTANCE hInstance)
{
static TCHAR szAppName[] = TEXT ("Modeless_Dialog") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wc ;
HWND hDialog;
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hIcon= LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RICHMEDIA));
wc.hCursor = 0;
wc.hbrBackground = (HBRUSH) GetStockObject(HOLLOW_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = L"szAppClassName";
wc.hInstance = GetModuleHandle(NULL) ;
RegisterClass(&wc);
HINSTANCE ff;
ff=GetModuleHandle(NULL);
HWND hwndtemp;
//hwndtemp = CreateWindow( L"szAppClassName", 0, WS_BORDER,
//0, 0, 0, 0, mhwnd, NULL,ff, NULL);
hwndtemp = CreateWindowEx(0x00000004, L"szAppClassName", 0, WS_CLIPSIBLINGS ,
0, 0, 0, 0, mhwnd, NULL,hInstance, NULL);
ShowWindow (hwnd, SW_SHOW) ; //并不在这里显示主窗口
// UpdateWindow (hwnd) ;
hDialog = CreateDialog (hInstance, MAKEINTRESOURCE(IDD_DIALOG1), hwnd, DlgProc) ;
while (GetMessage (&msg, NULL, 0, 0))
{
if(hDialog==0||!IsDialogMessage(hDialog,&msg))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
}
return msg.wParam ;
}
BOOL CALLBACK DlgProc (HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG :
return true;
case WM_COMMAND:
switch(wParam)
{
case(IDOK):
MessageBox(NULL, L"这是一个modeless对话框的例子",L"提示",MB_OK);
DestroyWindow(hDlg);
PostQuitMessage (0) ;
return TRUE;
}
}
return FALSE;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}