c语言messagebox用法打开的弹窗用什么函数关掉

本帖子已过去太久远了,不再提供回复功能。&嵌入式系统中没有给我们提供MessageBox,但是鉴于其功能强大,我们需要模拟之,一个模拟MessageBox函数为:
/**//*****************************************************************************************************************/*&&函数名称:MessageBox/*&&功能说明:弹出式对话框,显示提醒用户的信息/*&&参数说明:lpStr&---提醒用户的字符串输出信息/*&&TYPE&---输出格式(ID&OK&=&0,ID&OKCANCEL&=1)/*&&&返回值:返回&对话框接收的键值,只有两种KEY_OK,KEY_CANCEL/*****************************************************************************************************************typedef&enum&TYPE&{&ID_OK,ID_OKCANCEL&}MSG_TYPE;extern&BYTE&MessageBox(&LPBYTE&lpStr,BYTE&TYPE){&&&&&BYTE&keyValue&=&-1;&&&&&ClearScreen();&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&/*&清除屏幕*/&&&&&DisplayString(xPos,yPos,lpStr,TRUE);&&&&&&&&&&&/**//*显示字符串*/&&&&&/**//*&根据对话框类型决定是否显示确定,取消*/&&&&&switch(TYPY)&&&&&...{&&&&&&&&&case&ID_OK:&&&&&&&&&&&&&DisplayString(&<span style="COLOR: #,&yPos+High+<span style="COLOR: #,&&确定&,<span style="COLOR: #);&&&&&&&&&&&&&break;&&&&&&&&&case&ID_OKCANCEL:&&&&&&&&&&&&&DisplayString(<span style="COLOR: #,&yPos+High+<span style="COLOR: #,&&确定&,<span style="COLOR: #);&&&&&&&&&&&&&DisplayString(<span style="COLOR: #,&yPos+High+<span style="COLOR: #,&&取消&,<span style="COLOR: #);&&&&&&&&&&&&&break;&&&&&&&&&default:&&&&&}&&&&&DrawRect(<span style="COLOR: #,<span style="COLOR: #,<span style="COLOR: #9,yPos+High+<span style="COLOR: #+<span style="COLOR: #);&&&/**//*绘制外框*/&&&&&/**//*MessageBox是模式对话框,阻塞运行,等待按键*/&&&&&&while((keyValue&!=&KEY_OK)&||&(keyValue&!=&KEY_CANCEL))&&&&&&...{&&&&&&&&&&&keyValue&=&getSysKey();&&&&&&}&&&&&&&if(keyValue==KEY_OK)&&&&&&...{&&&&&&&&&&&return&ID_OK;&&&&&&}&&&&&&else&&&&&&...{&&&&&&&&&&&retrn&ID_CANCEL;&&&&&&}}
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:42206次
排名:千里之外
原创:12篇
评论:10条
(1)(4)(2)(3)(1)(1)(4)(1)(3)新手问题:弹出的对话框会暂停程序的执行,我想弹出的同时程序…【c语言吧】_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:534,718贴子:
新手问题:弹出的对话框会暂停程序的执行,我想弹出的同时程序…收藏
ssageBox( NULL, "这是一个普通的对话框。", "标题栏在这里", MB_OK ); 这样弹出的对话框会暂停程序的执行,我想弹出的同时程序不要停止,可以实现吗?麻烦高手给个例子,谢谢!
法1、创建线程法2、有相关创建窗口的函数自己实现 MessageBox
嗯嗯,多线程
还是创建窗口吧...一个模板...#include &windows.h&/*
Declare Windows procedure
*/LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);/*
Make the class name into a global variable
*/char szClassName[ ] = "CodeBlocksWindowsApp";int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow){
/* This is the handle for our window */
/* Here messages to the application are saved */
WNDCLASSEX
/* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisI
wincl.lpszClassName = szClassN
wincl.lpfnWndProc = WindowP
/* This function is called by windows */
wincl.style = CS_DBLCLKS;
/* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
/* No menu */
wincl.cbClsExtra = 0;
/* No extra bytes after the window class */
wincl.cbWndExtra = 0;
/* structure or the window instance */
/* Use Windows's default colour as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
/* Extended possibilites for variation */
szClassName,
/* Classname */
"Code::Blocks Template Windows App",
/* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT,
/* Windows decides the position */
CW_USEDEFAULT,
/* where the window ends up on the screen */
/* The programs width */
/* and height in pixels */
HWND_DESKTOP,
/* The window is a child-window to desktop */
/* No menu */
hThisInstance,
/* Program Instance handler */
/* No Window Creation data */
/* Make the window visible on the screen */
ShowWindow (hwnd, nCmdShow);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wP}/*
This function is called by the Windows function DispatchMessage()
*/LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
switch (message)
/* handle the messages */
case WM_DESTROY:
PostQuitMessage (0);
/* send a WM_QUIT to the message queue */
/* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
return 0;}
登录百度帐号推荐应用}

我要回帖

更多关于 c语言函数调用 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信