NO

Author Topic: messagebox in console program  (Read 14429 times)

CommonTater

  • Guest
Re: messagebox in console program
« Reply #15 on: October 16, 2011, 02:06:30 PM »
Hi Stephan;

If you really want to mess with someone...
Code: [Select]
#include <windows.h>

int main (void)
  { return MessageBox(NULL,"Click Yes or No....","Choose",MB_YESNO | MB_ICONINFORMATION); }

The return value is useable in Batch files (.bat) error levels and can be used to control branching according to the user's input...



Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: messagebox in console program
« Reply #16 on: October 16, 2011, 02:51:56 PM »
Example using that idea:
Code: [Select]
// ChooseYesNo.c
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

//int __cdecl WinMainCRTStartup(void)
int __cdecl mainCRTStartup(void)
{
ExitProcess(MessageBox(0, "Yes or No", "Choose", MB_YESNO | MB_ICONINFORMATION));
}
Code: [Select]
@ECHO OFF
@REM YesNo.bat
@ChooseYesNo.exe
@ECHO %ERRORLEVEL%

@IF NOT ERRORLEVEL 7 GOTO CaseYes

@ECHO No
GOTO TheEnd

:CaseYes
@ECHO Yes
GOTO TheEnd

:TheEnd
@ECHO TheEnd
« Last Edit: October 16, 2011, 03:05:18 PM by timovjl »
May the source be with you

CommonTater

  • Guest
Re: messagebox in console program
« Reply #17 on: October 17, 2011, 12:28:27 AM »
Example using that idea:


Yep... good one.