怎样用c语言做个最简单的软件界面来呢?看看这段代码
#include<windows.h>intWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPreInstance,LPSTRlpC...
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPreInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
MessageBox(NULL,"WinMain创建的窗口程序","WinMain",MB_OK);
return 0;
} 展开
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPreInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
MessageBox(NULL,"WinMain创建的窗口程序","WinMain",MB_OK);
return 0;
} 展开
3个回答
展开全部
//用windows最基本的api写的,还有很多方法可以做界面
#include<windows.h>
LRESULT CALLBACK WndProc(HWND ,UINT ,WPARAM ,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
WNDCLASS wndclass;
static TCHAR szClassname[]=TEXT("weigua");
MSG msg;
HWND hwnd;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor=LoadCursor(NULL,IDC_CROSS);
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=WndProc;
wndclass.lpszClassName=szClassname;
wndclass.lpszMenuName=NULL;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
if(!RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("RegisterClass!"),TEXT("ERROR"),MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(szClassname,TEXT("Fu"),WS_OVERLAPPEDWINDOW,0,0,200,200,NULL,NULL,hInstance,NULL);
UpdateWindow(hwnd);
ShowWindow(hwnd,nShowCmd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_CREATE:
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
#include<windows.h>
LRESULT CALLBACK WndProc(HWND ,UINT ,WPARAM ,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
WNDCLASS wndclass;
static TCHAR szClassname[]=TEXT("weigua");
MSG msg;
HWND hwnd;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor=LoadCursor(NULL,IDC_CROSS);
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=WndProc;
wndclass.lpszClassName=szClassname;
wndclass.lpszMenuName=NULL;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
if(!RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("RegisterClass!"),TEXT("ERROR"),MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(szClassname,TEXT("Fu"),WS_OVERLAPPEDWINDOW,0,0,200,200,NULL,NULL,hInstance,NULL);
UpdateWindow(hwnd);
ShowWindow(hwnd,nShowCmd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_CREATE:
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
要成功弹出这个对话框,关键问题是能不能调用MessageBox()这个函数,跟你在哪儿调用它没关系,只要你是win系统 并且包含了 <windows.h>头文件就可以,所以主函数用main()也可以。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <Windows.h>
int main() {
MessageBoxA(NULL, "和main有啥区别?“, "呵呵", MB_OK);
}
int main() {
MessageBoxA(NULL, "和main有啥区别?“, "呵呵", MB_OK);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询