Example #1
0
VOID DialogPromptsProcessHackerIsRunning(
    _In_ HWND hwndDlg
    )
{
    if (WindowsVersion > WINDOWS_VISTA && TaskDialogIndirect) // We're on Vista or above.
    {
        INT nButtonPressed = 0;

        TASKDIALOGCONFIG tdConfig = { sizeof(TASKDIALOGCONFIG) };
        tdConfig.hwndParent = hwndDlg;
        tdConfig.hInstance = PhLibImageBase;
        tdConfig.dwFlags = TDF_POSITION_RELATIVE_TO_WINDOW;
        tdConfig.nDefaultButton = IDOK;
        tdConfig.dwCommonButtons = TDCBF_OK_BUTTON;
        tdConfig.pszMainIcon = TD_INFORMATION_ICON;
        tdConfig.pszMainInstruction = L"Please close Process Hacker before continuing.";
        tdConfig.pszWindowTitle = PhApplicationName;
        //tdConfig.pszContent = L"Please close Process Hacker before continuing.";

        TaskDialogIndirect(&tdConfig, &nButtonPressed, NULL, NULL);
    }
    else
    {
        MSGBOXPARAMS mbParams = { sizeof(MSGBOXPARAMS) };
        mbParams.hwndOwner = hwndDlg;
        mbParams.hInstance = PhLibImageBase;
        mbParams.lpszText = L"Please close Process Hacker before continuing.";
        mbParams.lpszCaption = PhApplicationName;
        mbParams.dwStyle = MB_OK; // | MB_USERICON;
        //params.lpszIcon = MAKEINTRESOURCE(IDI_ICON1);

        MessageBoxIndirect(&mbParams);
    }
}
Example #2
0
int Clock_Message(HWND parent, const wchar_t* msg, const wchar_t* title, UINT uType, UINT uBeep)
{
	MSGBOXPARAMS mbp = {sizeof(MSGBOXPARAMS)};
	mbp.hwndOwner = parent;
	mbp.hInstance = api.hInstance;
	mbp.lpszText = msg;
	mbp.lpszCaption = title;
	mbp.dwStyle = MB_USERICON | uType;
	mbp.lpszIcon = MAKEINTRESOURCE(IDI_MAIN);
	mbp.dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
	if(uBeep != 0xFFFFFFFF) MessageBeep(uBeep);
	return MessageBoxIndirect(&mbp);
}
Example #3
0
int MyMessageBox(HWND hWnd, const TCHAR * text, const TCHAR * caption, DWORD style)
{
	MSGBOXPARAMS param;

	memset(& param, 0, sizeof(param));
	param.cbSize	  = sizeof(param);
	param.hwndOwner   = hWnd;
	param.hInstance   = GetModuleHandle(NULL);
	param.lpszText    = text;
	param.lpszCaption = caption;
	param.dwStyle     = style | MB_USERICON;
	param.lpszIcon    = MAKEINTRESOURCE(IDI_GRAPH);

	return MessageBoxIndirect(&param);
}
Example #4
0
void ConEmuAbout::OnInfo_About(LPCWSTR asPageName /*= NULL*/)
{
	InitCommCtrls();

	bool bOk = false;

	if (!asPageName && sLastOpenTab[0])
	{
		// Reopen last active tab
		asPageName = sLastOpenTab;
	}

	ReloadSysInfo();

	{
		DontEnable de;
		if (!mp_DpiAware)
			mp_DpiAware = new CDpiForDialog();
		HWND hParent = (ghOpWnd && IsWindowVisible(ghOpWnd)) ? ghOpWnd : ghWnd;
		// Modal dialog (CreateDialog)
		INT_PTR iRc = CDynDialog::ExecuteDialog(IDD_ABOUT, hParent, aboutProc, (LPARAM)asPageName);
		bOk = (iRc != 0 && iRc != -1);

		mh_AboutDlg = NULL;
		if (mp_DpiAware)
			mp_DpiAware->Detach();

		#ifdef _DEBUG
		// Any problems with dialog resource?
		if (!bOk) DisplayLastError(L"DialogBoxParam(IDD_ABOUT) failed");
		#endif
	}

	if (!bOk)
	{
		wchar_t* pszTitle = lstrmerge(gpConEmu->GetDefaultTitle(), L" About");
		DontEnable de;
		MSGBOXPARAMS mb = {sizeof(MSGBOXPARAMS), ghWnd, g_hInstance,
			pAbout,
			pszTitle,
			MB_USERICON, MAKEINTRESOURCE(IMAGE_ICON), 0, NULL, LANG_NEUTRAL
		};
		SafeFree(pszTitle);
		// Use MessageBoxIndirect instead of MessageBox to show our icon instead of std ICONINFORMATION
		MessageBoxIndirect(&mb);
	}
}
Example #5
0
void ShowHelpInfo(LPCTSTR szText,LPCTSTR szCaption,LPCTSTR lpszIcon)
{
	MSGBOXPARAMS msgbox ;

   msgbox.cbSize = sizeof(msgbox);
   msgbox.hwndOwner = m_hWnd;
   msgbox.hInstance = m_hInst;
   msgbox.lpszText = szText;
   msgbox.lpszCaption = szCaption;
   msgbox.dwStyle = MB_OK | MB_USERICON ;
   msgbox.lpszIcon = lpszIcon;
   msgbox.dwContextHelpId = 1;
   msgbox.lpfnMsgBoxCallback = NULL ;
   msgbox.dwLanguageId = MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL);

   MessageBoxIndirect(&msgbox);
}
Example #6
0
BOOL ShowMessage (HWND hParent, INT idCaption, INT idMessage)
{
    MSGBOXPARAMS mbp= {0};
    BOOL bRet;
    INT  i;

    mbp.cbSize = sizeof(mbp);
    mbp.hwndOwner = hParent;
    mbp.hInstance = g_hInst;
    mbp.lpszText = MAKEINTRESOURCE(idMessage);
    mbp.lpszCaption = MAKEINTRESOURCE(idCaption);
    mbp.dwStyle = MB_OK | MB_APPLMODAL;

    i = MessageBoxIndirect (&mbp);
    bRet = (IDOK==i);
    return bRet;
}
Example #7
0
File: wasap.c Project: 070499/xbmc
static void ShowAbout(void)
{
	MSGBOXPARAMS mbp = {
		sizeof(MSGBOXPARAMS),
		hWnd,
		hInst,
		ASAP_CREDITS
		"WASAP icons (C) 2005 Lukasz Sychowicz\n\n"
		ASAP_COPYRIGHT,
		APP_TITLE " " ASAP_VERSION,
		MB_OK | MB_USERICON,
		MAKEINTRESOURCE(IDI_APP),
		0,
		NULL,
		LANG_NEUTRAL
	};
	MessageBoxIndirect(&mbp);
}
Example #8
0
int message_box(LPCTSTR text, LPCTSTR caption, DWORD style, DWORD helpctxid)
{
    MSGBOXPARAMS mbox;
    
    /*
     * We use MessageBoxIndirect() because it allows us to specify a
     * callback function for the Help button.
     */
    mbox.cbSize = sizeof(mbox);
    /* Assumes the globals `hinst' and `hwnd' have sensible values. */
    mbox.hInstance = hinst;
    mbox.hwndOwner = hwnd;
    mbox.lpfnMsgBoxCallback = &message_box_help_callback;
    mbox.dwLanguageId = LANG_NEUTRAL;
    mbox.lpszText = text;
    mbox.lpszCaption = caption;
    mbox.dwContextHelpId = helpctxid;
    mbox.dwStyle = style;
    if (helpctxid != 0 && has_help()) mbox.dwStyle |= MB_HELP;
    return MessageBoxIndirect(&mbox);
}
Example #9
0
int BBMessageBox(int flg, const char *fmt, ...)
{
	char buffer[10000], *msg = buffer, *caption = "bbLean", *p;
	va_list arg;
	va_start(arg, fmt);
	vsprintf (buffer, fmt, arg);
	if ('#' == msg[0] && NULL != (p = strchr(msg+1, msg[0])))
		caption = msg+1, *p=0, msg = p+1;

	//return MessageBox (BBhwnd, msg, caption, flg | MB_SYSTEMMODAL | MB_SETFOREGROUND);

	MSGBOXPARAMS mp;
	ZeroMemory(&mp, sizeof mp);
	mp.cbSize = sizeof mp;
	mp.hInstance = hMainInstance;
	//mp.hwndOwner = NULL;
	mp.lpszText = msg;
	mp.lpszCaption = caption;
	mp.dwStyle = flg | MB_SYSTEMMODAL | MB_SETFOREGROUND | MB_USERICON;
	mp.lpszIcon = MAKEINTRESOURCE(IDI_BLACKBOX);
	MessageBeep(0);
	return MessageBoxIndirect(&mp);
}
Example #10
0
BOOLEAN DialogPromptExit(
    _In_ HWND hwndDlg
    )
{
    if (WindowsVersion > WINDOWS_VISTA && TaskDialogIndirect)
    {
        INT nButtonPressed = 0;

        TASKDIALOGCONFIG tdConfig = { sizeof(TASKDIALOGCONFIG) };
        tdConfig.hwndParent = hwndDlg;
        tdConfig.hInstance = PhLibImageBase;
        tdConfig.dwFlags = TDF_POSITION_RELATIVE_TO_WINDOW;
        tdConfig.nDefaultButton = IDNO;
        tdConfig.dwCommonButtons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON;
        tdConfig.pszMainIcon = TD_WARNING_ICON;
        tdConfig.pszMainInstruction = L"Exit Setup";
        tdConfig.pszWindowTitle = PhApplicationName;
        tdConfig.pszContent = L"Are you sure you want to cancel the Setup?";

        TaskDialogIndirect(&tdConfig, &nButtonPressed, NULL, NULL);

        return nButtonPressed == IDNO;
    }
    else
    {
        MSGBOXPARAMS mbParams = { sizeof(MSGBOXPARAMS) };
        mbParams.hwndOwner = hwndDlg;
        mbParams.hInstance = PhLibImageBase;
        mbParams.lpszText = L"Are you sure you want to cancel the Setup?";
        mbParams.lpszCaption = PhApplicationName;
        mbParams.dwStyle = MB_YESNO | MB_ICONEXCLAMATION;
        // | MB_USERICON;
        //params.lpszIcon = MAKEINTRESOURCE(IDI_ICON1);

        return MessageBoxIndirect(&mbParams) == IDNO;
    }
}
Example #11
0
void ConEmuAbout::OnInfo_About(LPCWSTR asPageName /*= NULL*/)
{
	InitCommCtrls();

	bool bOk = false;

	{
		DontEnable de;
		HWND hParent = (ghOpWnd && IsWindowVisible(ghOpWnd)) ? ghOpWnd : ghWnd;
		// Modal dialog
		INT_PTR iRc = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_ABOUT), hParent, aboutProc, (LPARAM)asPageName);
		bOk = (iRc != 0 && iRc != -1);

		ZeroStruct(m_Btns);
		mh_AboutDlg = NULL;

		#ifdef _DEBUG
		// Any problems with dialog resource?
		if (!bOk) DisplayLastError(L"DialogBoxParam(IDD_ABOUT) failed");
		#endif
	}

	if (!bOk)
	{
		wchar_t* pszTitle = lstrmerge(gpConEmu->GetDefaultTitle(), L" About");
		DontEnable de;
		MSGBOXPARAMS mb = {sizeof(MSGBOXPARAMS), ghWnd, g_hInstance,
			pAbout,
			pszTitle,
			MB_USERICON, MAKEINTRESOURCE(IMAGE_ICON), 0, NULL, LANG_NEUTRAL
		};
		SafeFree(pszTitle);
		// Use MessageBoxIndirect instead of MessageBox to show our icon instead of std ICONINFORMATION
		MessageBoxIndirect(&mb);
	}
}
Example #12
0
void OPENSSL_showfatal (const char *fmta,...)
{ va_list ap;
  TCHAR buf[256];
  const TCHAR *fmt;
  HANDLE h;

    if ((h=GetStdHandle(STD_ERROR_HANDLE)) != NULL &&
	GetFileType(h)!=FILE_TYPE_UNKNOWN)
    {	/* must be console application */
	va_start (ap,fmta);
	vfprintf (stderr,fmta,ap);
	va_end (ap);
	return;
    }

    if (sizeof(TCHAR)==sizeof(char))
	fmt=(const TCHAR *)fmta;
    else do
    { int    keepgoing;
      size_t len_0=strlen(fmta)+1,i;
      WCHAR *fmtw;

#ifdef _MSC_VER
	fmtw = (WCHAR *)_alloca (len_0*sizeof(WCHAR));
#else
	fmtw = (WCHAR *)alloca (len_0*sizeof(WCHAR));
#endif
	if (fmtw == NULL) { fmt=(const TCHAR *)L"no stack?"; break; }

#ifndef OPENSSL_NO_MULTIBYTE
	if (!MultiByteToWideChar(CP_ACP,0,fmta,len_0,fmtw,len_0))
#endif
	    for (i=0;i<len_0;i++) fmtw[i]=(WCHAR)fmta[i];

	for (i=0;i<len_0;i++)
	{   if (fmtw[i]==L'%') do
	    {	keepgoing=0;
		switch (fmtw[i+1])
		{   case L'0': case L'1': case L'2': case L'3': case L'4':
		    case L'5': case L'6': case L'7': case L'8': case L'9':
		    case L'.': case L'*':
		    case L'-':	i++; keepgoing=1; break;
		    case L's':	fmtw[i+1]=L'S';   break;
		    case L'S':	fmtw[i+1]=L's';   break;
		    case L'c':	fmtw[i+1]=L'C';   break;
		    case L'C':	fmtw[i+1]=L'c';   break;
		}
	    } while (keepgoing);
	}
	fmt = (const TCHAR *)fmtw;
    } while (0);

    va_start (ap,fmta);
    _vsntprintf (buf,sizeof(buf)/sizeof(TCHAR)-1,fmt,ap);
    buf [sizeof(buf)/sizeof(TCHAR)-1] = _T('\0');
    va_end (ap);

#if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
    /* this -------------v--- guards NT-specific calls */
    if (GetVersion() < 0x80000000 && IsService())
    {	HANDLE h = RegisterEventSource(0,_T("OPENSSL"));
	const TCHAR *pmsg=buf;
	ReportEvent(h,EVENTLOG_ERROR_TYPE,0,0,0,1,0,&pmsg,0);
	DeregisterEventSource(h);
    }
    else
#endif
    {	MSGBOXPARAMS         m;

	m.cbSize             = sizeof(m);
	m.hwndOwner          = NULL;
	m.lpszCaption        = _T("OpenSSL: FATAL");
	m.dwStyle            = MB_OK;
	m.hInstance          = NULL;
	m.lpszIcon           = IDI_ERROR;
	m.dwContextHelpId    = 0;
	m.lpfnMsgBoxCallback = NULL;
	m.dwLanguageId       = MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US);
	m.lpszText           = buf;

	MessageBoxIndirect (&m);
    }
}
Example #13
0
//---------------------------------------------------------------------------
int SteemIntro()
{
	EasyStr caption=T("Welcome to Steem"),text;

  text=T("Thank you for running the Steem Engine. We hope you will get many hours of enjoyment from this program. Before you can start there's just a few things to set up.");
#ifdef WIN32
  int Ret;
  MSGBOXPARAMS mbp;
  mbp.cbSize=sizeof(MSGBOXPARAMS);
  mbp.hwndOwner=NULL;
  mbp.hInstance=Inst;
  mbp.dwContextHelpId=0;
  mbp.lpfnMsgBoxCallback=NULL;
  mbp.dwLanguageId=GetUserDefaultLangID();
  mbp.lpszIcon=RCNUM(RC_ICO_APP);

  text+=" ";
  text+=T("Do you want to put a shortcut to Steem in your Start Menu?");
  mbp.lpszCaption=caption;
  mbp.lpszText=text.Text;
  mbp.dwStyle=MB_USERICON | MB_YESNO;
  if (MessageBoxIndirect(&mbp)==IDYES){
    ITEMIDLIST *idl;
    if (SHGetSpecialFolderLocation(NULL,CSIDL_PROGRAMS,&idl)==NOERROR){
      IMalloc *Mal;SHGetMalloc(&Mal);
      EasyStr Path;Path.SetLength(MAX_PATH);
      SHGetPathFromIDList(idl,Path);
      Mal->Free(idl);

      EasyStr ThisExeName=GetEXEFileName();
      CreateDirectory(Path+"\\Steem Engine",NULL);
      CreateLink(Path+"\\Steem Engine\\Steem Engine.lnk",ThisExeName,"The STE Emulating Engine");
      CreateLink(Path+"\\Steem Engine\\Readme.lnk",RunDir+"\\readme.txt","Steem Engine Info");
    }
  }
#elif defined(UNIX)
  alert.set_icons(&Ico64,ICO64_STEEM,&Ico16,ICO16_STEEM);
  if (1==alert.ask(XD,text,caption,T("Continue")+"|"+T("Abort"),0,1)){
		return 1;
  }
#endif

  caption=T("TOS Image");
  text=T("The most important file Steem needs to run is an image of the ST operating system TOS. If you haven't got one you cannot run Steem. They are easily downloadable from the internet, probably from the same place that you downloaded Steem. Alternatively you can get ST programs that will save out the TOS from an ST. After clicking OK find a TOS image file and click open. This setting, and all the other settings you are about to set, can be easily changed at any time when running Steem.");
#ifdef WIN32
	mbp.lpszText=text;
	mbp.lpszCaption=caption;
  mbp.dwStyle=MB_USERICON | MB_OK;
  MessageBoxIndirect(&mbp);
#elif defined(UNIX)
	alert.ask(XD,text,caption,T("Okay"),0,0);
#endif
  LOOP{
#ifdef WIN32
    ROMFile=FileSelect(NULL,T("Select TOS Image"),RunDir,FSTypes(3,NULL),1,true,"img");
#elif defined(UNIX)
		fileselect.set_corner_icon(&Ico16,ICO16_CHIP);
    ROMFile=fileselect.choose(XD,RunDir,"",T("Select TOS Image"),FSM_LOAD | FSM_LOADMUSTEXIST,
    												romfile_parse_routine,".img");
#endif
    if (ROMFile.IsEmpty()) return 1;

    if (load_TOS(ROMFile)==0) break;

    MessageBox((WINDOWTYPE)0,ROMFile+" "+T("is not a valid TOS"),T("Error Loading OS"),
                MB_ICONEXCLAMATION | MB_TASKMODAL | MB_TOPMOST | MB_SETFOREGROUND);
  }


	caption=T("Disk Images");
  text=T("The next few settings regard the way Steem emulates disks. Steem, and all other ST emulators, use files with the extension ST, STT, DIM or MSA on a PC drive for its floppy disks. This is the format most things you download for the ST will be in. If you have some of these files already then you can tell Steem which folder they are in. This will become your home folder and makes it easy to switch disks in and out of drives. If you don't have any then select a suitable folder on your PC hard disk and Steem will create a blank disk for you there.")+"\n\n"+
         T("Click cancel if you'd rather set up the home folder later.");

	bool proceed;
#ifdef WIN32
  mbp.lpszCaption=caption;
  mbp.lpszText=text;
  mbp.dwStyle=MB_USERICON | MB_OKCANCEL;
  Ret=MessageBoxIndirect(&mbp);
  proceed=(Ret==IDOK);
#elif defined(UNIX)
	proceed=!alert.ask(XD,text,caption,T("Okay")+"|"+T("Cancel"),0,1);
#endif

  if (proceed){
  	EasyStr Path;
#ifdef WIN32
    Path=ChooseFolder(NULL,T("Pick a Folder"),RunDir);
    if (Path.Empty()) Path=RunDir;
#elif defined(UNIX)
		fileselect.set_corner_icon(&Ico16,ICO16_FOLDER);
	  Path=fileselect.choose(XD,RunDir,"",T("Pick a Folder"),
	    FSM_CHOOSE_FOLDER | FSM_CONFIRMCREATE,folder_parse_routine,"");
#endif
		if (Path.NotEmpty()){
      DiskMan.HomeFol=Path;
      NO_SLASH(DiskMan.HomeFol);
      DiskMan.DisksFol=DiskMan.HomeFol;

    	bool Found=0;
      {
	      DirSearch ds;
		    if (ds.Find(DiskMan.HomeFol+SLASH+"*.*")){
		    	do{
            if (FileIsDisk(ds.Name)){
							Found=true;
							break;
		    		}
		    	}while (ds.Next());
		    }
	    }

      if (Found==0){
        if (DiskMan.CreateDiskImage(DiskMan.HomeFol+SLASH+T("Blank Disk")+".st",
                                    80*9*2,9,2)){
          FloppyDrive[0].SetDisk(DiskMan.HomeFol+SLASH+T("Blank Disk")+".st");
          FloppyDrive[0].DiskName=T("Blank Disk");
          DiskMan.InsertHistoryAdd(0,FloppyDrive[0].DiskName,FloppyDrive[0].GetDisk(),"");
        }
      }
    }
  }

  caption=T("Hard Drives");
  text=T("Steem can also emulate hard drives on the ST. This isn't as reliable as disk images, but it works for most things. You can have up to 10 hard drives, each one is mapped to a folder on your PC hard drive.")+"\n\n"+
         T("Would you like to select a folder to be ST hard drive C now?");
 	proceed=false;
#ifdef WIN32
  mbp.lpszText=text;
  mbp.lpszCaption=caption;
  mbp.dwStyle=MB_USERICON | MB_YESNO;
  Ret=MessageBoxIndirect(&mbp);
  if (Ret==IDYES){
  	proceed=true;
  }
#elif defined(UNIX)
	proceed=!alert.ask(XD,text,caption,T("Yes")+"|"+T("No"),0,1);
#endif
	if (proceed){
    int Let=0;
    EasyStr Mess[9];
    Mess[0]=T("Would you like to select a folder to be ST hard drive D now?");
    Mess[1]=T("Would you like to select a folder to be ST hard drive E now?");
    Mess[2]=T("Would you like to select a folder to be ST hard drive F now?");
    Mess[3]=T("Would you like to select a folder to be ST hard drive G now?");
    Mess[4]=T("Would you like to select a folder to be ST hard drive H now?");
    Mess[5]=T("Would you like to select a folder to be ST hard drive I now?");
    Mess[6]=T("Would you like to select a folder to be ST hard drive J now?");
    Mess[7]=T("Would you like to select a folder to be ST hard drive K now?");
    Mess[8]=T("Would you like to select a folder to be ST hard drive L now?");
    EasyStr Path=RunDir;
#ifdef WIN32
    do{
      Path=ChooseFolder(NULL,T("Pick a Folder"),Path);
      if (Path.Empty()) break;
		  NO_SLASH(Path);

      if (Let>=9) break;
      HardDiskMan.NewDrive(Path);
      mbp.lpszText=Mess[Let++];
      mbp.dwStyle=MB_USERICON | MB_YESNO;
      Ret=MessageBoxIndirect(&mbp);
    }while (Ret==IDYES);
#elif defined(UNIX)
		fileselect.set_corner_icon(&Ico16,ICO16_HARDDRIVE);
		do{
		  Path=fileselect.choose(XD,RunDir,"",T("Pick a Folder"),
		    FSM_CHOOSE_FOLDER | FSM_CONFIRMCREATE,folder_parse_routine,"");
		  if (Path.Empty()) break;
		  NO_SLASH(Path);

      if (Let>=9) break;
      HardDiskMan.NewDrive(Path);
			proceed=!alert.ask(XD,Mess[Let++],caption,T("Yes")+"|"+T("No"),1,1);
		}while(proceed);
#endif
  }

	caption=T("Get Ready For Steem!");
	text=T("Congratulations, Steem is now ready to go. Click on the yellow play button to start emulation. To release the PC mouse press the Pause/Break key. To stop emulation click on the run button again or press Shift + Pause/Break.")+
         "\n\n"+T("Have fun!");

#ifdef WIN32
  mbp.lpszCaption=caption;
  mbp.lpszText=text;
  mbp.dwStyle=MB_USERICON | MB_OK;
  MessageBoxIndirect(&mbp);
  return 0;
#elif defined(UNIX)
	alert.ask(XD,text,caption,T("Okay"),0,0);
  return 0;
#endif
}
Example #14
0
static int winMessageDlgPopup(Ihandle* ih, int x, int y)
{
  InativeHandle* parent = iupDialogGetNativeParent(ih);
  MSGBOXPARAMS MsgBoxParams;
  int result, num_but = 2;
  DWORD dwStyle = MB_TASKMODAL;
  char *icon, *buttons;
  (void)x;
  (void)y;

  if (!parent)
    parent = GetActiveWindow();

  icon = iupAttribGetStr(ih, "DIALOGTYPE");
  if (iupStrEqualNoCase(icon, "ERROR"))
    dwStyle |= MB_ICONERROR;
  else if (iupStrEqualNoCase(icon, "WARNING"))
    dwStyle |= MB_ICONWARNING;
  else if (iupStrEqualNoCase(icon, "INFORMATION"))
    dwStyle |= MB_ICONINFORMATION;
  else if (iupStrEqualNoCase(icon, "QUESTION"))
    dwStyle |= MB_ICONQUESTION;

  buttons = iupAttribGetStr(ih, "BUTTONS");
  if (iupStrEqualNoCase(buttons, "OKCANCEL"))
    dwStyle |= MB_OKCANCEL;
  else if (iupStrEqualNoCase(buttons, "YESNO"))
    dwStyle |= MB_YESNO;
  else
  {
    dwStyle |= MB_OK;
    num_but = 1;
  }

  if (IupGetCallback(ih, "HELP_CB"))
    dwStyle |= MB_HELP;

  if (num_but == 2 && iupAttribGetInt(ih, "BUTTONDEFAULT") == 2)
    dwStyle |= MB_DEFBUTTON2;
  else
    dwStyle |= MB_DEFBUTTON1;

  MsgBoxParams.cbSize = sizeof(MSGBOXPARAMS);
  MsgBoxParams.hwndOwner = parent;
  MsgBoxParams.hInstance = NULL;
  MsgBoxParams.lpszText = iupAttribGet(ih, "VALUE");
  MsgBoxParams.lpszCaption = iupAttribGet(ih, "TITLE");
  MsgBoxParams.dwStyle = dwStyle;
  MsgBoxParams.lpszIcon = NULL;
  MsgBoxParams.dwContextHelpId = (DWORD_PTR)ih;
  MsgBoxParams.lpfnMsgBoxCallback = (MSGBOXCALLBACK)winMessageDlgHelpCallback;
  MsgBoxParams.dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);

  result = MessageBoxIndirect(&MsgBoxParams);
  if (result == 0)
  {
    iupAttribSetStr(ih, "BUTTONRESPONSE", NULL);
    return IUP_ERROR;
  }

  if (result == IDNO || result == IDCANCEL)
    iupAttribSetStr(ih, "BUTTONRESPONSE", "2");
  else
    iupAttribSetStr(ih, "BUTTONRESPONSE", "1");

  return IUP_NOERROR;
}
Example #15
0
// 窗体事件捕捉过程
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  int x, y;
  HDC hdc;
  RECT rect;
  PAINTSTRUCT ps;
  MSGBOXPARAMS mbp;

  switch (uMsg) {
  // 新建窗口
  case WM_CREATE:
    // 调整窗口位置和尺寸
    GetWindowRect(hWnd, &rect);
    x = rect.left;
    y = rect.top;
    rect.right = rect.left + BOARD_WIDTH;
    rect.bottom = rect.top + BOARD_HEIGHT;
    AdjustWindowRect(&rect, WINDOW_STYLES, TRUE);
    MoveWindow(hWnd, x, y, rect.right - rect.left, rect.bottom - rect.top, TRUE);
    break;
  // 退出
  case WM_DESTROY:
    PostQuitMessage(0);
    break;
  // 菜单命令
  case WM_COMMAND:
    switch (LOWORD(wParam)) {
    case IDM_FILE_RED:
    case IDM_FILE_BLACK:
      Xqwl.bFlipped = (LOWORD(wParam) == IDM_FILE_BLACK);
      Startup();
      hdc = GetDC(Xqwl.hWnd);
      DrawBoard(hdc);
      ReleaseDC(Xqwl.hWnd, hdc);
      break;
    case IDM_FILE_EXIT:
      DestroyWindow(Xqwl.hWnd);
      break;
    case IDM_HELP_HOME:
      ShellExecute(NULL, NULL, "http://www.xqbase.com/", NULL, NULL, SW_SHOWNORMAL);
      break;
    case IDM_HELP_ABOUT:
      // 弹出带象棋小巫师图标的对话框
      MessageBeep(MB_ICONINFORMATION);
      mbp.cbSize = sizeof(MSGBOXPARAMS);
      mbp.hwndOwner = hWnd;
      mbp.hInstance = Xqwl.hInst;
      mbp.lpszText = cszAbout;
      mbp.lpszCaption = "关于象棋小巫师";
      mbp.dwStyle = MB_USERICON;
      mbp.lpszIcon = MAKEINTRESOURCE(IDI_APPICON);
      mbp.dwContextHelpId = 0;
      mbp.lpfnMsgBoxCallback = NULL;
      mbp.dwLanguageId = 0;
      MessageBoxIndirect(&mbp);
      break;
    }
    break;
  // 绘图
  case WM_PAINT:
    hdc = BeginPaint(Xqwl.hWnd, &ps);
    DrawBoard(hdc);
    EndPaint(Xqwl.hWnd, &ps);
    break;
  // 鼠标点击
  case WM_LBUTTONDOWN:
    x = FILE_LEFT + (LOWORD(lParam) - BOARD_EDGE) / SQUARE_SIZE;
    y = RANK_TOP + (HIWORD(lParam) - BOARD_EDGE) / SQUARE_SIZE;
    if (x >= FILE_LEFT && x <= FILE_RIGHT && y >= RANK_TOP && y <= RANK_BOTTOM) {
      ClickSquare(COORD_XY(x, y));
    }
    break;
  // 其他事件
  default:
    return DefWindowProc(hWnd, uMsg, wParam, lParam);
  }
  return FALSE;
}
Example #16
0
static int winMessageDlgPopup(Ihandle* ih, int x, int y)
{
  InativeHandle* parent = iupDialogGetNativeParent(ih);
  MSGBOXPARAMS MsgBoxParams;
  int result, button_def;
  DWORD dwStyle = MB_TASKMODAL;
  char *icon, *buttons;
  (void)x;
  (void)y;

  /* MessageBox is the only Windows pre-defined dialog that has a modal control,
     no need to force a parent dialog here. */

  icon = iupAttribGetStr(ih, "DIALOGTYPE");
  if (iupStrEqualNoCase(icon, "ERROR"))
    dwStyle |= MB_ICONERROR;
  else if (iupStrEqualNoCase(icon, "WARNING"))
    dwStyle |= MB_ICONWARNING;
  else if (iupStrEqualNoCase(icon, "INFORMATION"))
    dwStyle |= MB_ICONINFORMATION;
  else if (iupStrEqualNoCase(icon, "QUESTION"))
    dwStyle |= MB_ICONQUESTION;

  buttons = iupAttribGetStr(ih, "BUTTONS");
  if (iupStrEqualNoCase(buttons, "OKCANCEL"))
    dwStyle |= MB_OKCANCEL;
  else if (iupStrEqualNoCase(buttons, "RETRYCANCEL"))
    dwStyle |= MB_RETRYCANCEL;
  else if (iupStrEqualNoCase(buttons, "YESNO"))
    dwStyle |= MB_YESNO;
  else if (iupStrEqualNoCase(buttons, "YESNOCANCEL"))
    dwStyle |= MB_YESNOCANCEL;
  else
    dwStyle |= MB_OK;

  if (IupGetCallback(ih, "HELP_CB"))
    dwStyle |= MB_HELP;

  button_def = iupAttribGetInt(ih, "BUTTONDEFAULT");
  if (button_def == 3)
    dwStyle |= MB_DEFBUTTON3;
  else if (button_def == 2)
    dwStyle |= MB_DEFBUTTON2;
  else
    dwStyle |= MB_DEFBUTTON1;

  MsgBoxParams.cbSize = sizeof(MSGBOXPARAMS);
  MsgBoxParams.hwndOwner = parent;
  MsgBoxParams.hInstance = NULL;
  MsgBoxParams.lpszText = iupwinStrToSystem(iupAttribGet(ih, "VALUE"));
  MsgBoxParams.lpszCaption = iupwinStrToSystem(iupAttribGet(ih, "TITLE"));
  MsgBoxParams.dwStyle = dwStyle;
  MsgBoxParams.lpszIcon = NULL;
  MsgBoxParams.dwContextHelpId = (DWORD_PTR)ih;
  MsgBoxParams.lpfnMsgBoxCallback = (MSGBOXCALLBACK)winMessageDlgHelpCallback;
  MsgBoxParams.dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);

  result = MessageBoxIndirect(&MsgBoxParams);

  if (result == 0)  /* memory error */
  {
    iupAttribSet(ih, "BUTTONRESPONSE", NULL);
    return IUP_ERROR;
  }

  if (result == IDOK || result == IDYES || result == IDRETRY)
    iupAttribSet(ih, "BUTTONRESPONSE", "1");
  else if (result == IDCANCEL && iupStrEqualNoCase(buttons, "YESNOCANCEL"))
    iupAttribSet(ih, "BUTTONRESPONSE", "3");
  else
    iupAttribSet(ih, "BUTTONRESPONSE", "2");

  return IUP_NOERROR;
}