求个C语言写的弹出窗口的简单程序
3个回答
展开全部
#include <windows.h>
HWND NewWindow(HINSTANCE hInst,HWND hWnd,char *className,char *appName,RECT rect,WNDPROC wndProc)
{
WNDCLASSEX wclsx;
wclsx.cbClsExtra = NULL;
wclsx.cbSize = sizeof(wclsx);
wclsx.cbWndExtra = NULL;
wclsx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wclsx.hCursor = LoadCursor(NULL, IDC_ARROW);
wclsx.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wclsx.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
wclsx.hInstance = hInst;//GetModuleHandle(NULL);
wclsx.lpfnWndProc = wndProc;
wclsx.lpszClassName = className;
wclsx.lpszMenuName = NULL;
wclsx.style = NULL;
if (!RegisterClassEx(&wclsx))
return NULL;
HWND tmphWnd=CreateWindow(className,appName,WS_OVERLAPPEDWINDOW,
rect.left, rect.top, rect.right, rect.bottom,
NULL, 0, GetModuleHandle(NULL), NULL);
return tmphWnd;
}
HRESULT CALLBACK wndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_CLOSE:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
int WINAPI WinMain(HINSTANCE hInst,HINSTANCE,LPSTR szCommand,int)
{
MSG msg;
RECT rc={0,0,100,100 };
HWND hWnd=NewWindow(hInst,NULL,"Test","Test",rc,wndProc);
ShowWindow(hWnd,SW_NORMAL);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
HWND NewWindow(HINSTANCE hInst,HWND hWnd,char *className,char *appName,RECT rect,WNDPROC wndProc)
{
WNDCLASSEX wclsx;
wclsx.cbClsExtra = NULL;
wclsx.cbSize = sizeof(wclsx);
wclsx.cbWndExtra = NULL;
wclsx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wclsx.hCursor = LoadCursor(NULL, IDC_ARROW);
wclsx.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wclsx.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
wclsx.hInstance = hInst;//GetModuleHandle(NULL);
wclsx.lpfnWndProc = wndProc;
wclsx.lpszClassName = className;
wclsx.lpszMenuName = NULL;
wclsx.style = NULL;
if (!RegisterClassEx(&wclsx))
return NULL;
HWND tmphWnd=CreateWindow(className,appName,WS_OVERLAPPEDWINDOW,
rect.left, rect.top, rect.right, rect.bottom,
NULL, 0, GetModuleHandle(NULL), NULL);
return tmphWnd;
}
HRESULT CALLBACK wndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_CLOSE:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
int WINAPI WinMain(HINSTANCE hInst,HINSTANCE,LPSTR szCommand,int)
{
MSG msg;
RECT rc={0,0,100,100 };
HWND hWnd=NewWindow(hInst,NULL,"Test","Test",rc,wndProc);
ShowWindow(hWnd,SW_NORMAL);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
更多追问追答
追问
大哥,还有简单点的没?看起来没有那么复杂的?
追答
再简单的就是DialogBox函数了,就一行代码,可是得在vc++创建dialog设置. 文字很难表达怎么用. 祝你好运
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <windows.h>
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
MessageBox (NULL, TEXT ("Hello, Windows 98!"), TEXT ("HelloMsg"), 0) ;
return 0 ;
}
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
MessageBox (NULL, TEXT ("Hello, Windows 98!"), TEXT ("HelloMsg"), 0) ;
return 0 ;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
C语言能写弹出窗口吗?我不会,我知道C++可以写
追问
你先贴出来我看下吧。行吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询