Exemplo n.º 1
0
static INT_PTR CALLBACK Dialog_NewVersion_Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    Dialog_NewVersion_Data *  data;
    WCHAR *txt;

//[ ACCESSKEY_GROUP New Version Dialog
    if (WM_INITDIALOG == msg)
    {
        data = (Dialog_NewVersion_Data*)lParam;
        assert(NULL != data);
        SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)data);
        win::SetText(hDlg, _TR("SumatraPDF Update"));

        txt = str::Format(_TR("You have version %s"), data->currVersion);
        SetDlgItemText(hDlg, IDC_YOU_HAVE, txt);
        free(txt);

        txt = str::Format(_TR("New version %s is available. Download new version?"), data->newVersion);
        SetDlgItemText(hDlg, IDC_NEW_AVAILABLE, txt);
        free(txt);

        SetDlgItemText(hDlg, IDC_SKIP_THIS_VERSION, _TR("&Skip this version"));
        CheckDlgButton(hDlg, IDC_SKIP_THIS_VERSION, BST_UNCHECKED);
        SetDlgItemText(hDlg, IDOK, _TR("Download"));
        SetDlgItemText(hDlg, IDCANCEL, _TR("&No, thanks"));

        CenterDialog(hDlg);
        SetFocus(GetDlgItem(hDlg, IDOK));
        return FALSE;
    }
//] ACCESSKEY_GROUP New Version Dialog

    switch (msg)
    {
        case WM_COMMAND:
            data = (Dialog_NewVersion_Data*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
            assert(data);
            data->skipThisVersion = false;
            switch (LOWORD(wParam))
            {
                case IDOK:
                    if (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_SKIP_THIS_VERSION))
                        data->skipThisVersion = true;
                    EndDialog(hDlg, IDYES);
                    return TRUE;

                case IDCANCEL:
                    if (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_SKIP_THIS_VERSION))
                        data->skipThisVersion = true;
                    EndDialog(hDlg, IDNO);
                    return TRUE;

                case IDC_SKIP_THIS_VERSION:
                    return TRUE;
            }
            break;
    }
    return FALSE;
}
Exemplo n.º 2
0
/*
** About Dialog with one Command Button (Unload dialog on press)
** Center on Init rel. to main Window!
*/
BOOL CALLBACK AboutProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	case WM_INITDIALOG:
		CenterDialog(hWndDlg, GetParent(hWndDlg));
		hCursor=LoadCursor(NULL, IDC_HAND); // Windows 98/Me, Windows 2000/XP: Hand
		if(!hCursor)
			hCursor=LoadCursor(hInstance, MAKEINTRESOURCE(IDC_MY_HAND));
		//SetClassLong(GetDlgItem(hWndDlg, IDC_STATIC_MAIL), GCL_HCURSOR, (LPARAM)hCursor);
		//SetClassLong(GetDlgItem(hWndDlg, IDC_STATIC_URL), GCL_HCURSOR, (LPARAM)hCursor);
		return TRUE;
	case WM_CTLCOLORSTATIC:
		switch(GetDlgCtrlID((HWND)lParam))
		{
		case IDC_STATIC_MAIL:
		case IDC_STATIC_URL:
			SetBkMode((HDC)wParam, TRANSPARENT);
			SetTextColor((HDC)wParam, RGB(0x00, 0x00, 0xFF));
			return (BOOL)GetStockObject(NULL_BRUSH);
		case IDC_STATIC_DO:
			SetBkMode((HDC)wParam,TRANSPARENT);
			SetTextColor((HDC)wParam, RGB(0x00, 0xA0, 0x00));
			return (BOOL)GetStockObject(NULL_BRUSH);
		}
		break;
	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case IDOK:
			DestroyCursor(hCursor);
			EndDialog(hWndDlg, 1);
			return TRUE;
		case IDC_STATIC_URL:
			if(HIWORD(wParam)==STN_CLICKED)
			{
				ShellExecute(GetParent(hWndDlg), "open", "http://darkone.yo.lv", 0, 0, SW_SHOW);
				return TRUE;
			}
			break;
		case IDC_STATIC_MAIL:
			if(HIWORD(wParam)==STN_CLICKED)
			{
				ShellExecute(GetParent(hWndDlg), "open", "mailto:[email protected]?subject=PACK WinCmd Plugin", 0, 0, SW_SHOW);
				return TRUE;
			}
			break;
// 		case IDC_CHK_LCASE: FIXME
		}
		break;
	case WM_CLOSE:
		DestroyCursor(hCursor);
		EndDialog(hWndDlg, 0);
		return FALSE;
	}
	return FALSE;
}
Exemplo n.º 3
0
static INT_PTR CALLBACK Dialog_GoToPage_Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    HWND                    editPageNo;
    Dialog_GoToPage_Data *  data;

//[ ACCESSKEY_GROUP GoTo Page Dialog
    if (WM_INITDIALOG == msg)
    {
        data = (Dialog_GoToPage_Data*)lParam;
        assert(data);
        SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)data);
        win::SetText(hDlg, _TR("Go to page"));

        editPageNo = GetDlgItem(hDlg, IDC_GOTO_PAGE_EDIT);
        if (!data->onlyNumeric)
            SetWindowLong(editPageNo, GWL_STYLE, GetWindowLong(editPageNo, GWL_STYLE) & ~ES_NUMBER);
        assert(data->currPageLabel);
        SetDlgItemText(hDlg, IDC_GOTO_PAGE_EDIT, data->currPageLabel);
        ScopedMem<WCHAR> totalCount(str::Format(_TR("(of %d)"), data->pageCount));
        SetDlgItemText(hDlg, IDC_GOTO_PAGE_LABEL_OF, totalCount);

        Edit_SelectAll(editPageNo);
        SetDlgItemText(hDlg, IDC_STATIC, _TR("&Go to page:"));
        SetDlgItemText(hDlg, IDOK, _TR("Go to page"));
        SetDlgItemText(hDlg, IDCANCEL, _TR("Cancel"));

        CenterDialog(hDlg);
        SetFocus(editPageNo);
        return FALSE;
    }
//] ACCESSKEY_GROUP GoTo Page Dialog

    switch (msg)
    {
        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
                case IDOK:
                    data = (Dialog_GoToPage_Data*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
                    assert(data);
                    editPageNo = GetDlgItem(hDlg, IDC_GOTO_PAGE_EDIT);
                    data->newPageLabel = win::GetText(editPageNo);
                    EndDialog(hDlg, IDOK);
                    return TRUE;

                case IDCANCEL:
                    EndDialog(hDlg, IDCANCEL);
                    return TRUE;
            }
            break;
    }
    return FALSE;
}
//Simple plugin About box
INT_PTR WINAPI AboutDlgProcIntel(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM /*lParam*/)
{
	switch  (wMsg) 
	{
		case WM_INITDIALOG:
			{
				//Set window name
				string windowTitle = DDSExporterPluginName;
				windowTitle += DDSExporterPluginVersion;
				SetWindowText(hDlg, windowTitle.c_str());
                CenterDialog(hDlg);	
			}
            break;

		case WM_CHAR:
			{
				TCHAR chCharCode = TCHAR(wParam);
				if (chCharCode == VK_ESCAPE || chCharCode == VK_RETURN)
					EndDialog(hDlg, 0);
			}
			break;
 
		case WM_LBUTTONDOWN:
				EndDialog(hDlg, 0);
            break;

		case WM_COMMAND:
			switch  (COMMANDID(wParam)) 
			{
				case OK:
					EndDialog(hDlg, 0);
                    break;

				case CANCEL:
					EndDialog(hDlg, 0);
					break;

				default:
                    return FALSE;
            }
            break;

      default:
		  return  FALSE;
	
	} // switch (wMsg)

    return  TRUE;
}
Exemplo n.º 5
0
static INT_PTR CALLBACK Dialog_GetPassword_Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    Dialog_GetPassword_Data *data;

//[ ACCESSKEY_GROUP Password Dialog
    if (WM_INITDIALOG == msg)
    {
        data = (Dialog_GetPassword_Data*)lParam;
        win::SetText(hDlg, _TR("Enter password"));
        SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)data);
        EnableWindow(GetDlgItem(hDlg, IDC_REMEMBER_PASSWORD), data->remember != NULL);

        ScopedMem<WCHAR> txt(str::Format(_TR("Enter password for %s"), data->fileName));
        SetDlgItemText(hDlg, IDC_GET_PASSWORD_LABEL, txt);
        SetDlgItemText(hDlg, IDC_GET_PASSWORD_EDIT, L"");
        SetDlgItemText(hDlg, IDC_STATIC, _TR("&Password:"******"&Remember the password for this document"));
        SetDlgItemText(hDlg, IDOK, _TR("OK"));
        SetDlgItemText(hDlg, IDCANCEL, _TR("Cancel"));

        CenterDialog(hDlg);
        SetFocus(GetDlgItem(hDlg, IDC_GET_PASSWORD_EDIT));
        return FALSE;
    }
//] ACCESSKEY_GROUP Password Dialog

    switch (msg)
    {
        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
                case IDOK:
                    data = (Dialog_GetPassword_Data*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
                    assert(data);
                    data->pwdOut = win::GetText(GetDlgItem(hDlg, IDC_GET_PASSWORD_EDIT));
                    if (data->remember)
                        *data->remember = BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_REMEMBER_PASSWORD);
                    EndDialog(hDlg, IDOK);
                    return TRUE;

                case IDCANCEL:
                    EndDialog(hDlg, IDCANCEL);
                    return TRUE;
            }
            break;
    }
    return FALSE;
}
//Get name dialog
INT_PTR WINAPI DlgGetNameProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
	static string * str;

	switch  (wMsg) 
	{
		case WM_INITDIALOG:
			{
				if (lParam)
				{
					str = reinterpret_cast<string*>(lParam);
					SetDlgItemTextA(hDlg, IDC_NAME_EDIT, str->c_str());
				}
                CenterDialog(hDlg);	
			}
            break;


		case WM_COMMAND:
			switch  (COMMANDID(wParam)) 
			{
				case IDOK:
					{
						char buf[MAX_PATH+1] = {};
						GetDlgItemTextA(hDlg, IDC_NAME_EDIT, buf, MAX_PATH);
						*str = buf;
						str = NULL;
						EndDialog(hDlg, IDOK);
					}
                    break;

				case IDCANCEL:
					str = NULL;
					EndDialog(hDlg, IDCANCEL);
					break;

				default:
                    return FALSE;
            }
            break;

      default:
		  return  FALSE;
	
	} // switch (wMsg)

    return  TRUE;
}
Exemplo n.º 7
0
static INT_PTR CALLBACK Dialog_Find_Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    Dialog_Find_Data * data;

    switch (msg)
    {
    case WM_INITDIALOG:
//[ ACCESSKEY_GROUP Find Dialog
        data = (Dialog_Find_Data*)lParam;
        assert(data);
        SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)data);

        win::SetText(hDlg, _TR("Find"));
        SetDlgItemText(hDlg, IDC_STATIC, _TR("&Find what:"));
        SetDlgItemText(hDlg, IDC_MATCH_CASE, _TR("&Match case"));
        SetDlgItemText(hDlg, IDC_FIND_NEXT_HINT, _TR("Hint: Use the F3 key for finding again"));
        SetDlgItemText(hDlg, IDOK, _TR("Find"));
        SetDlgItemText(hDlg, IDCANCEL, _TR("Cancel"));
        if (data->searchTerm)
            SetDlgItemText(hDlg, IDC_FIND_EDIT, data->searchTerm);
        CheckDlgButton(hDlg, IDC_MATCH_CASE, data->matchCase ? BST_CHECKED : BST_UNCHECKED);
        data->editWndProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hDlg, IDC_FIND_EDIT), GWLP_WNDPROC, (LONG_PTR)Dialog_Find_Edit_Proc);
        Edit_SelectAll(GetDlgItem(hDlg, IDC_FIND_EDIT));

        CenterDialog(hDlg);
        SetFocus(GetDlgItem(hDlg, IDC_FIND_EDIT));
        return FALSE;
//] ACCESSKEY_GROUP Find Dialog
    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDOK:
            data = (Dialog_Find_Data*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
            assert(data);
            data->searchTerm = win::GetText(GetDlgItem(hDlg, IDC_FIND_EDIT));
            data->matchCase = BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_MATCH_CASE);
            EndDialog(hDlg, IDOK);
            return TRUE;

        case IDCANCEL:
            EndDialog(hDlg, IDCANCEL);
            return TRUE;
        }
        break;
    }
    return FALSE;
}
Exemplo n.º 8
0
static INT_PTR CALLBACK Dialog_PdfAssociate_Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    Dialog_PdfAssociate_Data *  data;

//[ ACCESSKEY_GROUP Associate Dialog
    if (WM_INITDIALOG == msg)
    {
        data = (Dialog_PdfAssociate_Data*)lParam;
        assert(data);
        SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)data);
        win::SetText(hDlg, _TR("Associate with PDF files?"));
        SetDlgItemText(hDlg, IDC_STATIC, _TR("Make SumatraPDF default application for PDF files?"));
        SetDlgItemText(hDlg, IDC_DONT_ASK_ME_AGAIN, _TR("&Don't ask me again"));
        CheckDlgButton(hDlg, IDC_DONT_ASK_ME_AGAIN, BST_UNCHECKED);
        SetDlgItemText(hDlg, IDOK, _TR("&Yes"));
        SetDlgItemText(hDlg, IDCANCEL, _TR("&No"));

        CenterDialog(hDlg);
        SetFocus(GetDlgItem(hDlg, IDOK));
        return FALSE;
    }
//] ACCESSKEY_GROUP Associate Dialog

    switch (msg)
    {
        case WM_COMMAND:
            data = (Dialog_PdfAssociate_Data*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
            assert(data);
            data->dontAskAgain = (BST_CHECKED == IsDlgButtonChecked(hDlg, IDC_DONT_ASK_ME_AGAIN));
            switch (LOWORD(wParam))
            {
                case IDOK:
                    EndDialog(hDlg, IDYES);
                    return TRUE;

                case IDCANCEL:
                    EndDialog(hDlg, IDNO);
                    return TRUE;

                case IDC_DONT_ASK_ME_AGAIN:
                    return TRUE;
            }
            break;
    }
    return FALSE;
}
Exemplo n.º 9
0
/*
 * License callback
 */
INT_PTR CALLBACK LicenseCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message) {
	case WM_INITDIALOG:
		apply_localization(IDD_LICENSE, hDlg);
		CenterDialog(hDlg);
		SetDlgItemTextA(hDlg, IDC_LICENSE_TEXT, gplv3);
		break;
	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDOK:
		case IDCANCEL:
			reset_localization(IDD_LICENSE);
			EndDialog(hDlg, LOWORD(wParam));
			return (INT_PTR)TRUE;
		}
	}
	return (INT_PTR)FALSE;
}
Exemplo n.º 10
0
/****************************************************************************

    FUNCTION: PasswordProc(HWND, WORD, WPARAM, LPARAM)

    PURPOSE:  Processes messages for "Password" dialog box

    MESSAGES:

    WM_INITDIALOG - initialize dialog box
    WM_COMMAND    - Input received

****************************************************************************/
BOOL WINAPI PasswordProc(HWND hDlg, WORD wMessage, WPARAM wParam, LPARAM lParam)
{
static char __far *lpsz;

    switch (wMessage)
    {
    case WM_INITDIALOG:
        lpsz = (char __far *)lParam;
        if (lpumb->szBuffer[0] != ' ')
           {
           SetDlgItemText(hDlg, IDM_PASSWORD_INCORRECT, "Incorrect Password");
           }
        else
           SetDlgItemText(hDlg, IDM_PASSWORD_INCORRECT, "");

        wsprintf(lpumb->szBuffer, "Enter Password for %s", (LPSTR)lParam);
        SetDlgItemText(hDlg, IDM_PASSWORD_TEXT, lpumb->szBuffer);
        SetDlgItemText(hDlg, IDM_NEW_PASSWORD_NAME_TEXT, "");
        CenterDialog(GetParent(hDlg), hDlg); /* center on parent */
        return TRUE;

    case WM_SETFOCUS:
        SetFocus(GetDlgItem(hDlg, IDM_NEW_PASSWORD_NAME_TEXT));
        return TRUE;

    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDM_PASSWORD_RENAME:
            GetDlgItemText(hDlg, IDM_NEW_PASSWORD_NAME_TEXT, lpumb->lpPassword, 80);
            EndDialog(hDlg, wParam);
            break;
        case IDM_PASSWORD_CANCEL:
            lpumb->szPassword[0] = '\0';
            EndDialog(hDlg, wParam);
            break;
        case IDM_PASSWORD_HELP:
            WinHelp(hDlg,szHelpFileName,HELP_CONTEXT, (DWORD)(HELPID_PASSWORD));
        }
        return TRUE;
    }
    return FALSE;
}
Exemplo n.º 11
0
static INT_PTR CALLBACK Dialog_CustomZoom_Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    Dialog_CustomZoom_Data *data;

    switch (msg)
    {
    case WM_INITDIALOG:
//[ ACCESSKEY_GROUP Zoom Dialog
        data = (Dialog_CustomZoom_Data *)lParam;
        assert(data);
        SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)data);

        SetupZoomComboBox(hDlg, IDC_DEFAULT_ZOOM, data->forChm, data->zoomArg);

        win::SetText(hDlg, _TR("Zoom factor"));
        SetDlgItemText(hDlg, IDC_STATIC, _TR("&Magnification:"));
        SetDlgItemText(hDlg, IDOK, _TR("Zoom"));
        SetDlgItemText(hDlg, IDCANCEL, _TR("Cancel"));

        CenterDialog(hDlg);
        SetFocus(GetDlgItem(hDlg, IDC_DEFAULT_ZOOM));
        return FALSE;
//] ACCESSKEY_GROUP Zoom Dialog

    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDOK:
            data = (Dialog_CustomZoom_Data *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
            assert(data);
            data->zoomResult = GetZoomComboBoxValue(hDlg, IDC_DEFAULT_ZOOM, data->forChm, data->zoomArg);
            EndDialog(hDlg, IDOK);
            return TRUE;

        case IDCANCEL:
            EndDialog(hDlg, IDCANCEL);
            return TRUE;
        }
        break;
    }
    return FALSE;
}
Exemplo n.º 12
0
static INT_PTR CALLBACK Dialog_AddFav_Proc(HWND hDlg, UINT msg, WPARAM wParam,
    LPARAM lParam)
{
    if (WM_INITDIALOG == msg) {
        Dialog_AddFav_Data *data = (Dialog_AddFav_Data *)lParam;
        assert(data);
        SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)data);
        win::SetText(hDlg, _TR("Add Favorite"));
        ScopedMem<WCHAR> s(str::Format(_TR("Add page %s to favorites with (optional) name:"), data->pageNo));
        SetDlgItemText(hDlg, IDC_ADD_PAGE_STATIC, s);
        SetDlgItemText(hDlg, IDOK, _TR("OK"));
        SetDlgItemText(hDlg, IDCANCEL, _TR("Cancel"));
        if (data->favName) {
            SetDlgItemText(hDlg, IDC_FAV_NAME_EDIT, data->favName);
            Edit_SelectAll(GetDlgItem(hDlg, IDC_FAV_NAME_EDIT));
        }
        CenterDialog(hDlg);
        SetFocus(GetDlgItem(hDlg, IDC_FAV_NAME_EDIT));
        return FALSE;
    }

    if (WM_COMMAND == msg) {
        Dialog_AddFav_Data *data = (Dialog_AddFav_Data *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
        assert(data);
        WORD cmd = LOWORD(wParam);
        if (IDOK == cmd) {
            ScopedMem<WCHAR> name(win::GetText(GetDlgItem(hDlg, IDC_FAV_NAME_EDIT)));
            str::TrimWS(name);
            if (!str::IsEmpty(name.Get()))
                data->favName = name.StealData();
            else
                data->favName = NULL;
            EndDialog(hDlg, IDOK);
            return TRUE;
        } else if (IDCANCEL == cmd) {
            EndDialog(hDlg, IDCANCEL);
            return TRUE;
        }
    }

    return FALSE;
}
Exemplo n.º 13
0
////////////////////////////////////////////////////////////////////
// BOOL WINAPI CProgress::DlgProc
//
////////////////////////////////////////////////////////////////////
BOOL WINAPI CProgress::DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
    case WM_INITDIALOG:
    {
        //Save the this pointer, since this is a static method
        Busy();
        CProgress* pThis = (CProgress*)lParam;
        SetWindowLongPtrA(hWnd, GWLP_USERDATA, (LONG_PTR)pThis);

        //On INIT we know we have a valid hWnd to store
        pThis->m_hWnd = hWnd;

        CenterDialog(hWnd);
        return TRUE;
    }
    break;

    case WM_COMMAND:
    {
        // All buttons are handled the same way
        //Restore instance pointer, since this is a static function
        CProgress* pThis = (CProgress*)GetWindowLongPtrA(hWnd, GWLP_USERDATA);

        switch(GET_WM_COMMAND_ID(wParam, lParam))
        {
        case IDCANCEL:
            Busy();
            pThis->m_fCancel = TRUE;
            return TRUE;
        }
        return FALSE;
    }
    break;

    default:
        return FALSE;
    }
}
Exemplo n.º 14
0
/**************************************************************************
*
* FUNCTION NAME: ProcessProdInfoDialog
*
* DESCRIPTION:
*
*
* INPUT PARAMETERS:
*     None.
*
* OUTPUT PARAMETERS:
*     None.
*
**************************************************************************/
MRESULT EXPENTRY ProcessProdInfoDialog (HWND hwnd, 
                                        ULONG msg,
                                        MPARAM mp1, 
                                        MPARAM mp2)
{
   switch (msg)
   {
		case WM_INITDLG:
			CenterDialog (hwnd);
			if (gfRegistered)
			{
				WinSetDlgItemText (hwnd, PROD_REG_NAME_ID, gszRegName);
			}
			else
			{
				WinSetDlgItemText (hwnd, PROD_REG_TO_ID, "Unregistered");
				WinSetDlgItemText (hwnd, PROD_REG_NAME_ID, "Please register the game.");
			}
         return (0);

      case WM_COMMAND :
         switch (SHORT1FROMMP (mp1))
         {
            case DID_OK:
               WinDismissDlg (hwnd, DID_OK);
               return (0);

            default:
               break;
         }
			break;

      default:
		   break;
   }

   return (WinDefDlgProc (hwnd, msg, mp1, mp2));
}
Exemplo n.º 15
0
static bool CreatePropertiesWindow(HWND hParent, PropertiesLayout* layoutData)
{
    CrashIf(layoutData->hwnd);
    HWND hwnd = CreateWindow(
           PROPERTIES_CLASS_NAME, PROPERTIES_WIN_TITLE,
           WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU,
           CW_USEDEFAULT, CW_USEDEFAULT,
           CW_USEDEFAULT, CW_USEDEFAULT,
           NULL, NULL,
           ghinst, NULL);
    if (!hwnd)
        return false;

    layoutData->hwnd = hwnd;
    layoutData->hwndParent = hParent;
    ToggleWindowStyle(hwnd, WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT, IsUIRightToLeft(), GWL_EXSTYLE);

    // get the dimensions required for the about box's content
    RectI rc;
    PAINTSTRUCT ps;
    HDC hdc = BeginPaint(hwnd, &ps);
    UpdatePropertiesLayout(layoutData, hdc, &rc);
    EndPaint(hwnd, &ps);

    // resize the new window to just match these dimensions
    // (as long as they fit into the current monitor's work area)
    WindowRect wRc(hwnd);
    ClientRect cRc(hwnd);
    RectI work = GetWorkAreaRect(WindowRect(hParent));
    wRc.dx = min(rc.dx + wRc.dx - cRc.dx, work.dx);
    wRc.dy = min(rc.dy + wRc.dy - cRc.dy, work.dy);
    MoveWindow(hwnd, wRc.x, wRc.y, wRc.dx, wRc.dy, FALSE);
    CenterDialog(hwnd, hParent);

    ShowWindow(hwnd, SW_SHOW);
    return true;
}
Exemplo n.º 16
0
/*-------
 * ConfigDlgProc
 *	Description:	Manage add data source name dialog
 *	Input	 :	hdlg --- Dialog window handle
 *				wMsg --- Message
 *				wParam - Message parameter
 *				lParam - Message parameter
 *	Output	 :	TRUE if message processed, FALSE otherwise
 *-------
 */
LRESULT			CALLBACK
ConfigDlgProc(HWND hdlg,
			  UINT wMsg,
			  WPARAM wParam,
			  LPARAM lParam)
{
	LPSETUPDLG	lpsetupdlg;
	ConnInfo   *ci;
	DWORD		cmd;
	char		strbuf[64];

	switch (wMsg)
	{
			/* Initialize the dialog */
		case WM_INITDIALOG:
			lpsetupdlg = (LPSETUPDLG) lParam;
			ci = &lpsetupdlg->ci;

			/* Hide the driver connect message */
			ShowWindow(GetDlgItem(hdlg, DRV_MSG_LABEL), SW_HIDE);
			LoadString(s_hModule, IDS_ADVANCE_SAVE, strbuf, sizeof(strbuf));
			SetWindowText(GetDlgItem(hdlg, IDOK), strbuf);

			SetWindowLongPtr(hdlg, DWLP_USER, lParam);
			CenterDialog(hdlg); /* Center dialog */

			/*
			 * NOTE: Values supplied in the attribute string will always
			 */
			/* override settings in ODBC.INI */

			memcpy(&ci->drivers, &globals, sizeof(globals));
			/* Get the rest of the common attributes */
			getDSNinfo(ci, CONN_DONT_OVERWRITE);

			/* Fill in any defaults */
			getDSNdefaults(ci);

			/* Initialize dialog fields */
			SetDlgStuff(hdlg, ci);

			if (lpsetupdlg->fNewDSN || !ci->dsn[0])
				ShowWindow(GetDlgItem(hdlg, IDC_MANAGEDSN), SW_HIDE);
			if (lpsetupdlg->fDefault)
			{
				EnableWindow(GetDlgItem(hdlg, IDC_DSNAME), FALSE);
				EnableWindow(GetDlgItem(hdlg, IDC_DSNAMETEXT), FALSE);
			}
			else
				SendDlgItemMessage(hdlg, IDC_DSNAME,
							 EM_LIMITTEXT, (WPARAM) (MAXDSNAME - 1), 0L);

			SendDlgItemMessage(hdlg, IDC_DESC,
							   EM_LIMITTEXT, (WPARAM) (MAXDESC - 1), 0L);
			return TRUE;		/* Focus was not set */

			/* Process buttons */
		case WM_COMMAND:
			switch (cmd = GET_WM_COMMAND_ID(wParam, lParam))
			{
					/*
					 * Ensure the OK button is enabled only when a data
					 * source name
					 */
					/* is entered */
				case IDC_DSNAME:
					if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE)
					{
						char		szItem[MAXDSNAME];	/* Edit control text */

						/* Enable/disable the OK button */
						EnableWindow(GetDlgItem(hdlg, IDOK),
									 GetDlgItemText(hdlg, IDC_DSNAME,
												szItem, sizeof(szItem)));
						return TRUE;
					}
					break;

					/* Accept results */
				case IDOK:
				case IDAPPLY:
					lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWLP_USER);
					/* Retrieve dialog values */
					if (!lpsetupdlg->fDefault)
						GetDlgItemText(hdlg, IDC_DSNAME,
									   lpsetupdlg->ci.dsn,
									   sizeof(lpsetupdlg->ci.dsn));
					/* Get Dialog Values */
					GetDlgStuff(hdlg, &lpsetupdlg->ci);

					/* Update ODBC.INI */
					SetDSNAttributes(hdlg, lpsetupdlg, NULL);
					if (IDAPPLY == cmd)
						break;
					/* Return to caller */
				case IDCANCEL:
					EndDialog(hdlg, wParam);
					return TRUE;

				case IDC_TEST:
				{
					lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWLP_USER);
					if (NULL != lpsetupdlg)
					{
						EnvironmentClass *env = EN_Constructor();
						ConnectionClass *conn = NULL;
						char    szMsg[SQL_MAX_MESSAGE_LENGTH];

						/* Get Dialog Values */
						GetDlgStuff(hdlg, &lpsetupdlg->ci);
						if (env)
							conn = CC_Constructor();
						if (conn)
						{
							char *emsg;
							int errnum;

							EN_add_connection(env, conn);
							memcpy(&conn->connInfo, &lpsetupdlg->ci, sizeof(ConnInfo));
							CC_initialize_pg_version(conn);
							if (CC_connect(conn, AUTH_REQ_OK, NULL) > 0)
							{
								if (CC_get_errornumber(conn) != 0)
								{
									CC_get_error(conn, &errnum, &emsg);
									snprintf(szMsg, sizeof(szMsg), "Warning: %s", emsg);
								}
								else
									strncpy(szMsg, "Connection successful", sizeof(szMsg));
								emsg = szMsg;
							}
							else
							{
								CC_get_error(conn, &errnum, &emsg);
							}
							MessageBox(lpsetupdlg->hwndParent, emsg, "Connection Test", MB_ICONEXCLAMATION | MB_OK);
							EN_remove_connection(env, conn);
							CC_Destructor(conn);
						}
						if (env)
							EN_Destructor(env);
						return TRUE;
					}
					break;
				}
				case IDC_DATASOURCE:
					lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWLP_USER);
					DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_DRV),
					 hdlg, ds_options1Proc, (LPARAM) &lpsetupdlg->ci);
					return TRUE;

				case IDC_DRIVER:
					lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWLP_USER);
					DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_OPTIONS_GLOBAL),
						 hdlg, global_optionsProc, (LPARAM) &lpsetupdlg->ci);

					return TRUE;
				case IDC_MANAGEDSN:
					lpsetupdlg = (LPSETUPDLG) GetWindowLong(hdlg, DWLP_USER);
					if (DialogBoxParam(s_hModule, MAKEINTRESOURCE(DLG_DRIVER_CHANGE),
						hdlg, manage_dsnProc,
						(LPARAM) lpsetupdlg) > 0)
						EndDialog(hdlg, 0);

					return TRUE;
			}
			break;
		case WM_CTLCOLORSTATIC:
			if (lParam == (LPARAM)GetDlgItem(hdlg, IDC_NOTICE_USER))
			{
				HBRUSH hBrush = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
				SetTextColor((HDC)wParam, RGB(255, 0, 0));
				return (long)hBrush;
			}
			break;
	}

	/* Message not processed */
	return FALSE;
}
Exemplo n.º 17
0
VOID OnInitDialog(HWND hwnd)
{
    int i, n;
    double e;
    char buf[64], *p;
    HICON hIcon;

    // set big icon
    hIcon = LoadIconA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(1));
    SendMessageA(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
    // set small icon
    hIcon = (HICON)LoadImageA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(1),
        IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
    SendMessageA(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
    // set window title
    SetWindowText(hwnd, progname);

    for (i = 0; i < hack_argcount; i++)
    {
        SetDlgItemTextA(hwnd, IDC_ARGNAME00 + i, hack_arginfo[i].name);

        switch (hack_arginfo[i].type)
        {
        case t_Bool:
            if (*(Bool *)hack_arginfo[i].data)
                SetDlgItemTextA(hwnd, IDC_ARGVAL00 + i, "True");
            else
                SetDlgItemTextA(hwnd, IDC_ARGVAL00 + i, "False");
            break;

        case t_Int:
            n = *(INT *)hack_arginfo[i].data;
            SetDlgItemInt(hwnd, IDC_ARGVAL00 + i, n, TRUE);
            break;

        case t_Float:
            e = *(float *)hack_arginfo[i].data;
            sprintf(buf, "%g", e);
            SetDlgItemTextA(hwnd, IDC_ARGVAL00 + i, buf);
            break;

        case t_String:
            p = *(char **)hack_arginfo[i].data;
            SetDlgItemTextA(hwnd, IDC_ARGVAL00 + i, p);
            break;
        }
    }

    for (; i <= 23; i++)
    {
        ShowWindow(GetDlgItem(hwnd, IDC_ARGNAME00 + i), SW_HIDE);
        ShowWindow(GetDlgItem(hwnd, IDC_ARGVAL00 + i), SW_HIDE);
    }

    if (hack_count_enabled)
    {
        n = ss.modeinfo.count;
        SetDlgItemInt(hwnd, IDC_COUNTVAL, n, TRUE);
    }
    else
    {
        ShowWindow(GetDlgItem(hwnd, IDC_COUNTNAME), SW_HIDE);
        ShowWindow(GetDlgItem(hwnd, IDC_COUNTVAL), SW_HIDE);
    }

    if (hack_cycles_enabled)
    {
        n = ss.modeinfo.cycles;
        SetDlgItemInt(hwnd, IDC_CYCLESVAL, n, TRUE);
    }
    else
    {
        ShowWindow(GetDlgItem(hwnd, IDC_CYCLESNAME), SW_HIDE);
        ShowWindow(GetDlgItem(hwnd, IDC_CYCLESVAL), SW_HIDE);
    }

    if (hack_size_enabled)
    {
        n = ss.modeinfo.size;
        SetDlgItemInt(hwnd, IDC_SIZEVAL, n, TRUE);
    }
    else
    {
        ShowWindow(GetDlgItem(hwnd, IDC_SIZENAME), SW_HIDE);
        ShowWindow(GetDlgItem(hwnd, IDC_SIZEVAL), SW_HIDE);
    }

    CenterDialog(hwnd);
}
Exemplo n.º 18
0
static WDL_DLGRET DialogProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if (INT_PTR r = SNM_HookThemeColorsMessage(hwnd, uMsg, wParam, lParam))
		return r;

	static BR_SearchObject* s_searchObject = NULL;
	#ifndef _WIN32
		static bool s_positionSet = false;
	#endif

	switch(uMsg)
	{
		case WM_INITDIALOG:
		{
			s_searchObject = (BR_SearchObject*)lParam;
			SetVersionMessage(hwnd, s_searchObject);
			SetTimer(hwnd, 1, 100, NULL);

			#ifdef _WIN32
				CenterDialog(hwnd, GetParent(hwnd), HWND_TOPMOST);
			#else
				s_positionSet = false;
			#endif
		}
		break;

		#ifndef _WIN32
			case WM_ACTIVATE:
			{
				// SetWindowPos doesn't seem to work in WM_INITDIALOG on OSX
				// when creating a dialog with DialogBox so call here
				if (!s_positionSet)
					CenterDialog(hwnd, GetParent(hwnd), HWND_TOPMOST);
				s_positionSet = true;
			}
			break;
		#endif

		case WM_COMMAND:
		{
			switch(LOWORD(wParam))
			{
				case IDC_BR_VER_DOWNLOAD:
				{
					if (s_searchObject->GetStatus(NULL, NULL) == NO_CONNECTION)
					{
						s_searchObject->RestartSearch();
						SetVersionMessage(hwnd, s_searchObject);
						SetTimer(hwnd, 1, 100, NULL);
					}
					if (s_searchObject->GetStatus(NULL, NULL) == OFFICIAL_AVAILABLE)
					{
						ShellExecute(NULL, "open", SWS_URL_DOWNLOAD, NULL, NULL, SW_SHOWNORMAL);
						EndDialog(hwnd, 0);
					}
					else if (s_searchObject->GetStatus(NULL, NULL) == BETA_AVAILABLE)
					{
						ShellExecute(NULL, "open", SWS_URL_BETA_DOWNLOAD, NULL, NULL, SW_SHOWNORMAL);
						EndDialog(hwnd, 0);
					}
				}
				break;

				case IDC_BR_VER_OFF:
				{
					ShellExecute(NULL, "open", SWS_URL_DOWNLOAD , NULL, NULL, SW_SHOWNORMAL);
					EndDialog(hwnd, 0);
				}
				break;

				case IDC_BR_VER_BETA:
				{
					ShellExecute(NULL, "open", SWS_URL_BETA_DOWNLOAD, NULL, NULL, SW_SHOWNORMAL);
					EndDialog(hwnd, 0);
				}
				break;

				case IDCANCEL:
				{
					EndDialog(hwnd, 0);
				}
				break;
			}
		}
		break;

		case WM_TIMER:
		{
			SendMessage(GetDlgItem(hwnd, IDC_BR_VER_PROGRESS), PBM_SETPOS, (int)(s_searchObject->GetProgress() * 100.0), 0);

			if (s_searchObject->GetStatus(NULL, NULL) != SEARCH_INITIATED)
			{
				SetVersionMessage(hwnd, s_searchObject);
				KillTimer(hwnd, 1);
			}
		}
		break;

		case WM_DESTROY:
		{
			KillTimer(hwnd, 1);
			s_searchObject = NULL;
		}
		break;
	}
	return 0;
}
Exemplo n.º 19
0
BOOL WINAPI UIProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) 
{
	static GPtr globals = NULL;		  // need to be static	

	switch  (wMsg)
	{

	case WM_INITDIALOG:
		{
			LV_ITEM		LvItem;
			LV_COLUMN	LstColVal, LstColProp;
			int			i;

			CenterDialog(hDlg);

			// set up globals	
			globals		= (GPtr) lParam;
			gList		= GetDlgItem(hDlg,1011); // get the ID of the ListView	
			LVProcPrev	= (WNDPROC)SetWindowLong(gList, GWL_WNDPROC, (DWORD)LVProc);    

			// Here we put the info on the Column headers
			// this is not data, only name of each header we like
			memset(&LstColVal,0,sizeof(LstColVal)); // Reset Column

			LstColVal.mask		= LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM|LVCF_ORDER;	// Type of mask
			LstColVal.cx		= 0x64;											// width between each coloum
			LstColVal.pszText	= "Value";										// 
			LstColVal.iOrder	= 1;											// put editable field on right side

			LstColProp			= LstColVal;
			LstColProp.pszText	= "Property";
			LstColProp.iOrder	= 0;

			// Inserting Columns as much as we want
			ListView_InsertColumn(gList, 0, &LstColVal);
			ListView_InsertColumn(gList, 1, &LstColProp);

			//  Setting common properties Of Items:
			memset(&LvItem,0,sizeof(LvItem)); // Reset Item Struct
			LvItem.mask			= LVIF_TEXT|LVCF_WIDTH|LVCF_SUBITEM;	// Text Style
			LvItem.cchTextMax	= 256;									// Max size of test

			// allocate mem for items
			ListView_SetItemCount(gList, PI_MAX);

			// insert items
			for(i=0; i<PI_MAX; i++)
			{
				ListView_SetPair(gList, LvItem, i,its(gIntProps[i].value), gIntProps[i].name );
			}

			ShowWindow(hDlg,SW_NORMAL); 
			UpdateWindow(hDlg); 

			return FALSE;
		}

	case WM_NOTIFY:
	{
		switch( ((LPNMHDR)lParam)->code  )
		{
			case LVN_BEGINLABELEDIT: 
			{
				break;
			}

			case LVN_ENDLABELEDIT: 
			{
				int iIndex;
				char tempstr[255]="";
				HWND hEdit;

				iIndex = ListView_GetNextItem(gList,-1,LVNI_FOCUSED);
				if( iIndex != - 1 )
				{
					//save to list
					hEdit = ListView_GetEditControl(gList);
					GetWindowText(hEdit, tempstr, sizeof(tempstr));
					ListView_SetItemText(gList, iIndex,0,tempstr);

					//save to globals
					gIntProps[iIndex].value = ListView_ReadInt(gList, iIndex, 0);
				}
				break;
			}
		}
		break;
	}

	case WM_COMMAND:
	{
		int item;
		int cmd;

		item = COMMANDID (wParam);              // WIN32 Change
		cmd  = HIWORD(wParam);

		switch (item)
		{
			case ok:
				if (cmd == BN_CLICKED)
					state = STATE_AGAIN;
				break;

			case cancel:
				if (cmd == BN_CLICKED)
					state = STATE_CANCEL;
				break;
		} 
		return FALSE;
	}
	} 
	return FALSE;
}
Exemplo n.º 20
0
INT_PTR
CALLBACK
DebuggerDataDlgProc(
    HWND    hDlg,
    UINT    msg,
    WPARAM  wParam,
    LPARAM  lParam)
/*++

Routine Description:

    Common dialog box to get some input from the user

Arguments:

    Refer to DialogProc in MSDN

Returns:

    TRUE - Message Handled
    FALSE - Message not handled

--*/
{
    static PDEBUGGER_INFO debuggerInfo;

    switch(msg)
    {
        case WM_INITDIALOG:
        {
            //
            // Insert *specific* dialog initialization code here.
            // lParam can contain information required for initialization.
            //

            //
            // Set dialog and application Icon
            //
            HICON hIcon = LoadIcon(ghInstance, MAKEINTRESOURCE(IDI_APP_ICON_SM));
            SendMessage (hDlg, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon);
            hIcon = LoadIcon(ghInstance, MAKEINTRESOURCE(IDI_APP_ICON));
            SendMessage (hDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon);

            CenterDialog(hDlg);

            debuggerInfo = (PDEBUGGER_INFO)lParam;

            SetWindowText(
                    GetDlgItem(hDlg, IDC_TEXT_DEBUGGER),
                    debuggerInfo->debuggerPath.c_str());

            SetWindowText(
                    GetDlgItem(hDlg, IDC_EDIT_CMDLINE),
                    debuggerInfo->cmdLine.c_str());

            return TRUE;
        }
        case WM_COMMAND:
        {
            switch(wParam)
            {
                case IDOK:
                {
                    //
                    // Set result here and terminate the dialog
                    //

                    TCHAR dataBuffer[64] = {0};

                    GetWindowText(
                            GetDlgItem(hDlg, IDC_EDIT_CMDLINE),
                            dataBuffer,
                            sizeof(dataBuffer) / sizeof(TCHAR));

                    debuggerInfo->cmdLine = dataBuffer;

                    EndDialog(hDlg, IDOK);
                    return TRUE;
                }
            }

            break;
        }
        case WM_DESTROY:
        {
            return TRUE;
        }
    }

    return FALSE;
}
Exemplo n.º 21
0
/**************************************************************************
*
* FUNCTION NAME: ProcessSizeDialog
*
* DESCRIPTION:
*
*
* INPUT PARAMETERS:
*     None.
*
* OUTPUT PARAMETERS:
*     None.
*
**************************************************************************/
MRESULT EXPENTRY ProcessSizeDialog (HWND hwnd, 
                                    ULONG msg,
                                    MPARAM mp1, 
                                    MPARAM mp2)
{
   USHORT i;
	BITMAPINFOHEADER bmpData;
	static USHORT usPosition;

   switch (msg)
   {
      case WM_INITDLG :
			/* Set the marks on the slider */
			for (i = 0;  i < 10;  i++)
			{
            WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETTICKSIZE,
                                  MPFROM2SHORT(i, 2), NULL);
			}

			/* Label the ends and default position of the slider */
         WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETTICKSIZE,
                                  MPFROM2SHORT(0, 5), NULL);
         WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETTICKSIZE,
                                  MPFROM2SHORT(5, 5), NULL);
         WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETTICKSIZE,
                                  MPFROM2SHORT(9, 5), NULL);
         WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETSCALETEXT,
                                  MPFROMSHORT(0), MPFROMP(TINY_LABEL));
         WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETSCALETEXT,
                                  MPFROMSHORT(5), MPFROMP(NORMAL_LABEL));
         WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETSCALETEXT,
                                  MPFROMSHORT(9), MPFROMP(HUGE_LABEL));

			/* Set the slider position */
			usPosition = gsObjectSize - 1;
         WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETSLIDERINFO,
                                  MPFROM2SHORT(SMA_SLIDERARMPOSITION,
											 				  SMA_INCREMENTVALUE),
											 MPFROMSHORT(usPosition));

		   /* Center the dialog box in the frame window of the parent */
			CenterDialog (hwnd);
         return (0);

      case WM_COMMAND :
         switch (SHORT1FROMMP (mp1))
         {
            case DID_OK:
				   /* Scale the bitmaps according to the set size */
					gsObjectSize = usPosition + 1;
			   	for (i = 0;  i < NUM_BMPS;  i++)
					{
						LoadAndStretchBitmap (i);
					}

					/* Redraw the screen */
               WinInvalidateRect (hwndDefClient, NULL, FALSE);

               WinDismissDlg (hwnd, DID_OK);
               return (0);

            case DID_CANCEL:
				   /* Dismiss the dialog without saving the values */
               WinDismissDlg (hwnd, DID_CANCEL);
               return (0);

			   case DID_HELP:
				   /* Display the keys help panel */
    				WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP,
                            MPFROM2SHORT(PANEL_OBJECTSIZE, NULL), 
									 MPFROMSHORT(HM_RESOURCEID));
               return (0);

            default:
               break;
         }
			break;

      case WM_CONTROL :
         switch (SHORT1FROMMP(mp1))
			{
				case SLIDER_ID:
				   if (SHORT2FROMMP(mp1) == SLN_CHANGE)
					{
                  usPosition = (USHORT) WinSendDlgItemMsg (hwnd, 
						                        SLIDER_ID,
                                          SLM_QUERYSLIDERINFO,
                                          MPFROM2SHORT (SMA_SLIDERARMPOSITION,
													                 SMA_INCREMENTVALUE),
                                          NULL);
					}
					break;

				default:
					break;
			}
			break;

      default:
		   break;
   }

   return (WinDefDlgProc (hwnd, msg, mp1, mp2));
}
Exemplo n.º 22
0
/**************************************************************************
*
* FUNCTION NAME: ProcessKeyDialog
*
* DESCRIPTION:
*
*
* INPUT PARAMETERS:
*     None.
*
* OUTPUT PARAMETERS:
*     None.
*
**************************************************************************/
MRESULT EXPENTRY ProcessKeyDialog (HWND hwnd, 
                                   ULONG msg,
                                   MPARAM mp1, 
                                   MPARAM mp2)
{
	USHORT         usScanCode;
	static ULONG   ulButton = UP_TEXT_ID;
	static KEYDEFS stLocalDefs;
	static PUSHORT pusKeyDef;

   switch (msg)
   {
      case WM_INITDLG :
		   /* Store the current key settings */
			stLocalDefs = gstKeyDefs;
			pusKeyDef = &(stLocalDefs.usUpKey);

			/* Set the text for each field in the dialog box */
			WinSetDlgItemText (hwnd, UP_TEXT_ID, 
										 	 szScanCode[stLocalDefs.usUpKey]);
			WinSetDlgItemText (hwnd, DOWN_TEXT_ID, 
											 szScanCode[stLocalDefs.usDownKey]);
			WinSetDlgItemText (hwnd, TURN_TEXT_ID,
											 szScanCode[stLocalDefs.usTurnKey]);
			WinSetDlgItemText (hwnd, THRUST_TEXT_ID,
											 szScanCode[stLocalDefs.usThrustKey]);
			WinSetDlgItemText (hwnd, FIRE_TEXT_ID,
											 szScanCode[stLocalDefs.usFireKey]);
			WinSetDlgItemText (hwnd, SMART_TEXT_ID,
											 szScanCode[stLocalDefs.usSmartKey]);
			WinSetDlgItemText (hwnd, HYPER_TEXT_ID,
											 szScanCode[stLocalDefs.usHyperKey]);

		   /* Set the UP button to the clicked state */
         WinPostMsg (WinWindowFromID (hwnd , UP_ID), BM_CLICK, 
			             MPFROMSHORT (TRUE), MPVOID);

			/* Set the appropriate button toggle */
			if (stLocalDefs.fTurnThrust)
			{
         	WinPostMsg (WinWindowFromID (hwnd , TURN_THRUST_ID), BM_CLICK, 
			   	          MPFROMSHORT (TRUE), MPVOID);
				WinSetDlgItemText (hwnd, TURN_ID, "Turn");
				WinSetDlgItemText (hwnd, THRUST_ID, "Thrust");
			}
			else
			{
         	WinPostMsg (WinWindowFromID (hwnd , LEFT_RIGHT_ID), BM_CLICK, 
			   	          MPFROMSHORT (TRUE), MPVOID);
				WinSetDlgItemText (hwnd, TURN_ID, "Left");
				WinSetDlgItemText (hwnd, THRUST_ID, "Right");
			}

		   /* Center the dialog box in the frame window of the parent */
			CenterDialog (hwnd);
         return (0);

      case WM_COMMAND :
         switch (SHORT1FROMMP (mp1))
         {
            case DID_OK:
				   /* Save the key selections in the global list and save them */
					gstKeyDefs = stLocalDefs;
               WinDismissDlg (hwnd, DID_OK);
               return (0);

            case DID_CANCEL:
				   /* Dismiss the dialog without saving the values */
               WinDismissDlg (hwnd, DID_CANCEL);
               return (0);

			   case DID_HELP:
				   /* Display the keys help panel */
    				WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP,
                            MPFROM2SHORT(PANEL_KEYS, NULL), 
									 MPFROMSHORT(HM_RESOURCEID));
               return (0);
         }
			break;

      case WM_CONTROL :
         switch (SHORT1FROMMP (mp1))
			{
				case UP_ID:
					ulButton = UP_TEXT_ID;
					pusKeyDef = &(stLocalDefs.usUpKey);
					break;

				case DOWN_ID:
					ulButton = DOWN_TEXT_ID;
					pusKeyDef = &(stLocalDefs.usDownKey);
					break;

				case TURN_ID:
					ulButton = TURN_TEXT_ID;
					pusKeyDef = &(stLocalDefs.usTurnKey);
					break;

				case THRUST_ID:
					ulButton = THRUST_TEXT_ID;
					pusKeyDef = &(stLocalDefs.usThrustKey);
					break;

				case FIRE_ID:
					ulButton = FIRE_TEXT_ID;
					pusKeyDef = &(stLocalDefs.usFireKey);
					break;

				case SMART_ID:
					ulButton = SMART_TEXT_ID;
					pusKeyDef = &(stLocalDefs.usSmartKey);
					break;

				case HYPER_ID:
					ulButton = HYPER_TEXT_ID;
					pusKeyDef = &(stLocalDefs.usHyperKey);
					break;

				case TURN_THRUST_ID:
					WinSetDlgItemText (hwnd, TURN_ID, "Turn");
					WinSetDlgItemText (hwnd, THRUST_ID, "Thrust");
					stLocalDefs.fTurnThrust = TRUE;
					break;

				case LEFT_RIGHT_ID:
					WinSetDlgItemText (hwnd, TURN_ID, "Left");
					WinSetDlgItemText (hwnd, THRUST_ID, "Right");
					stLocalDefs.fTurnThrust = FALSE;
					break;

				default:
					break;
			}

			/* Take the focus away from the radiobuttons */
			WinSetFocus (HWND_DESKTOP, WinWindowFromID (hwnd, UP_TEXT_ID));
			break;

	   case WM_CHAR :
		   /* Get the scancode and store it in the appropriate place in array */
			if (!(SHORT1FROMMP(mp1) & KC_KEYUP))
			{
		   	usScanCode = CHAR4FROMMP(mp1);
				WinSetDlgItemText (hwnd, ulButton, szScanCode[usScanCode]);
				*pusKeyDef = usScanCode;
			}
			return (0);

      default:
		   break;
   }

   return (WinDefDlgProc (hwnd, msg, mp1, mp2));
}
Exemplo n.º 23
0
/**************************************************************************
*
* FUNCTION NAME: ProcessHiScoreDialog
*
* DESCRIPTION:
*
*
* INPUT PARAMETERS:
*     None.
*
* OUTPUT PARAMETERS:
*     None.
*
**************************************************************************/
MRESULT EXPENTRY ProcessHiScoreDialog (HWND hwnd, 
                                       ULONG msg,
                                       MPARAM mp1, 
                                       MPARAM mp2)
{
   HWND  hwndPage;
   ULONG ulPageId;
   ULONG ipt = 0;
	INT   i;
   CHAR  szMleBuffer[512];

   switch (msg)
   {
		case WM_INITDLG:
			for (i = 0;  i < NUM_HISCORES;  i++)
			{
   			/*
    			* Insert a page of the notebook
    			*/
   			ulPageId = (LONG) WinSendDlgItemMsg (hwnd, NOTEBOOK_ID,
        									  BKM_INSERTPAGE, NULL,
        									  MPFROM2SHORT((BKA_STATUSTEXTON | 
											  					 BKA_AUTOPAGESIZE | BKA_MAJOR),
        									  BKA_LAST));

				sprintf (szMleBuffer, "Page %d of %d", i + 1, NUM_HISCORES);
   			WinSendDlgItemMsg (hwnd, NOTEBOOK_ID,
        							    BKM_SETSTATUSLINETEXT, MPFROMLONG(ulPageId),
        								 MPFROMP(szMleBuffer));
				

				sprintf (szMleBuffer, "%d", i + 1);
   			WinSendDlgItemMsg (hwnd, NOTEBOOK_ID,
        								 BKM_SETTABTEXT, MPFROMLONG(ulPageId),
        								 MPFROMP(szMleBuffer));
   			WinSendDlgItemMsg (hwnd, NOTEBOOK_ID,
        								 BKM_SETDIMENSIONS, MPFROM2SHORT(40,25),
        								 MPFROMSHORT(BKA_MAJORTAB));
				
   			hwndPage = WinCreateWindow (hwnd,
													 WC_MLE,
      											 NULL,
      											 WS_VISIBLE | MLS_READONLY,
         	                            0,
         	                            0,
         	                            0,
         	                            0,
         	                            NULLHANDLE,
         	                            HWND_TOP,
         	                            0,
         	                            NULL,
         	                            NULL);

   			WinSendDlgItemMsg (hwnd, NOTEBOOK_ID,
         							 BKM_SETPAGEWINDOWHWND, MPFROMLONG(ulPageId),
         							 MPFROMHWND(hwndPage));
				
   			WinSendMsg (hwndPage, MLM_SETIMPORTEXPORT,
         					MPFROMP(szMleBuffer),
         					MPFROMSHORT(sizeof(szMleBuffer)));
				
     			sprintf (szMleBuffer, 
				         HISCORE_TEXT,
							i + 1,
							stHiscore[i].szName,
							stHiscore[i].lScore,
							stHiscore[i].szDate,
							stHiscore[i].sAliens,
							stHiscore[i].sHitRate,
							stHiscore[i].sWave + 1,
							stHiscore[i].sShips,
							stHiscore[i].sSmarts,
							(stHiscore[i].fBullets) ? "ON" : "OFF");
				
   			WinSendMsg (hwndPage, MLM_IMPORT, &ipt,
         				   MPFROMSHORT(strlen(szMleBuffer)));
				
   			WinSendDlgItemMsg (hwnd, NOTEBOOK_ID,
         							 BKM_SETPAGEWINDOWHWND, MPFROMLONG(ulPageId),
         							 MPFROMHWND(hwndPage));
			}

			CenterDialog (hwnd);
			return (0);
				
      case WM_COMMAND :
         switch (SHORT1FROMMP (mp1))
         {
            case DID_OK:
				   /* Dismiss the dialog */
               WinDismissDlg (hwnd, DID_OK);
               return (0);

			   case DID_HELP:
				   /* Display the keys help panel */
    				WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP,
                            MPFROM2SHORT(PANEL_HIGHSCORE, NULL), 
									 MPFROMSHORT(HM_RESOURCEID));
               return (0);
         }
			break;

      default:
		   break;
   }

   return (WinDefDlgProc (hwnd, msg, mp1, mp2));
}
Exemplo n.º 24
0
MRESULT EXPENTRY DetailsDllWndProc (HWND hDlg, USHORT Msg, MPARAM mp1, MPARAM mp2)

{
static PSHORT pDetailEntry;
CHAR   TitleStr[41];


switch (Msg)
  {
  case WM_INITDLG:
       pDetailEntry = PVOIDFROMMP (mp2);

       strcpy (TitleStr, "Details ");
       strcat (TitleStr, pShowTableData[*pDetailEntry].Name);
       WinSetWindowText (hDlg, TitleStr);


       /*--- get current libpath --*/

       if (!GetLibPath (Libpath, MAX_LIBPATH_SIZE, ErrorStr))
         {
         WinMessageBox (HWND_DESKTOP, hWndFrame, ErrorStr,
		        ApplTitle, 0, MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
         WinDismissDlg (hDlg, FALSE);
         break;
         }


       /*--- fill exported procedures ---*/

       if (!_FillExportedProcedures (hDlg, *pDetailEntry, ErrorStr))
         {
         WinMessageBox (HWND_DESKTOP, hWndFrame, ErrorStr,
		        ApplTitle, 0, MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
         WinDismissDlg (hDlg, FALSE);
         break;
         }


       /*--- fill imported modules ---*/

       if (!_FillImportedModules (hDlg, *pDetailEntry, ErrorStr))
         {
         WinMessageBox (HWND_DESKTOP, hWndFrame, ErrorStr,
		        ApplTitle, 0, MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
         WinDismissDlg (hDlg, FALSE);
         break;
         }


       CenterDialog (HWND_DESKTOP, hDlg);

       WinSetFocus (HWND_DESKTOP, WinWindowFromID (hDlg, LID_DETAILS_DLL_EXP_RES));
       return ((MRESULT) TRUE);


  case WM_COMMAND:
        switch (SHORT1FROMMP(mp1))
	 {
	 case DID_CANCEL:
	      WinDismissDlg (hDlg, FALSE);
	      break;
	 }
       break;


  default:
       return WinDefDlgProc (hDlg, Msg, mp1, mp2);
  }


return NULL;
}
Exemplo n.º 25
0
/**************************************************************************
*
* FUNCTION NAME: ProcessSpeedDialog
*
* DESCRIPTION:
*
*
* INPUT PARAMETERS:
*     None.
*
* OUTPUT PARAMETERS:
*     None.
*
**************************************************************************/
MRESULT EXPENTRY ProcessSpeedDialog (HWND hwnd, 
                                     ULONG msg,
                                     MPARAM mp1, 
                                     MPARAM mp2)
{
   USHORT i;
	static USHORT usPosition;

   switch (msg)
   {
      case WM_INITDLG :
			/* Set the marks on the slider */
			for (i = 0;  i < 10;  i++)
			{
            WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETTICKSIZE,
                                  MPFROM2SHORT(i, 2), NULL);
			}

			/* Label the ends of the slider */
         WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETTICKSIZE,
                                  MPFROM2SHORT(0, 5), NULL);
         WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETTICKSIZE,
                                  MPFROM2SHORT(9, 5), NULL);
         WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETSCALETEXT,
                                  MPFROMSHORT(0), MPFROMP(SLOW_LABEL));
         WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETSCALETEXT,
                                  MPFROMSHORT(9), MPFROMP(FAST_LABEL));

			/* Set the slider position */
			usPosition = (gFramesPerSec / 5) - 1;
         WinSendDlgItemMsg (hwnd, SLIDER_ID, SLM_SETSLIDERINFO,
                                  MPFROM2SHORT(SMA_SLIDERARMPOSITION,
											 				  SMA_INCREMENTVALUE),
											 MPFROMSHORT(usPosition));

		   /* Center the dialog box in the frame window of the parent */
			CenterDialog (hwnd);
         return (0);

      case WM_COMMAND :
         switch (SHORT1FROMMP (mp1))
         {
            case DID_OK:
				   /* Calculate the frame rate from the position of the arm */
					gFramesPerSec = (usPosition + 1) * 5;

					/* Reset the timer to tick at this rate */
   				WinStartTimer (hab,
               				   hwndDefClient,
           					      TIMER_ID,
                 					1000/gFramesPerSec);

               WinDismissDlg (hwnd, DID_OK);
               return (0);

            case DID_CANCEL:
				   /* Dismiss the dialog without saving the values */
               WinDismissDlg (hwnd, DID_CANCEL);
               return (0);

			   case DID_HELP:
				   /* Display the keys help panel */
    				WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP,
                            MPFROM2SHORT(PANEL_GAMESPEED, NULL), 
									 MPFROMSHORT(HM_RESOURCEID));
               return (0);

            default:
               break;
         }
			break;

      case WM_CONTROL :
         switch (SHORT1FROMMP(mp1))
			{
				case SLIDER_ID:
				   if (SHORT2FROMMP(mp1) == SLN_CHANGE)
					{
                  usPosition = (USHORT) WinSendDlgItemMsg (hwnd, 
						                        SLIDER_ID,
                                          SLM_QUERYSLIDERINFO,
                                          MPFROM2SHORT (SMA_SLIDERARMPOSITION,
													                 SMA_INCREMENTVALUE),
                                          NULL);
					}
					break;

				default:
					break;
			}
			break;

      default:
		   break;
   }

   return (WinDefDlgProc (hwnd, msg, mp1, mp2));
}
Exemplo n.º 26
0
INT_PTR
CALLBACK
RecoveryStatusDlgProc(
    HWND    hDlg,
    UINT    msg,
    WPARAM  wParam,
    LPARAM  lParam)
/*++

Routine Description:

    This dialog box opens up if the user selects Recover on HandleCrash
    dialog. This dialog box basically transfer control to CRecoveryHandler
    in most cases. It also allows the user to terminate the crashing process
    in case it is not recovering.

Arguments:

    Refer to DialogProc in MSDN

Returns:

    TRUE - Message Handled
    FALSE - Message not handled

--*/
{
    CRecoveryHandler *pRecoveryHandler = NULL;

    if (msg == WM_INITDIALOG)
    {
        SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
        pRecoveryHandler = (CRecoveryHandler *)lParam;
    }
    else
    {
        pRecoveryHandler = (CRecoveryHandler *)
                                GetWindowLongPtr(hDlg, GWLP_USERDATA);
    }

    switch(msg)
    {
        case WM_INITDIALOG:
        {
            HICON hIcon = LoadIcon(ghInstance, MAKEINTRESOURCE(IDI_APP_ICON_SM));
            SendMessage (hDlg, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon);
            hIcon = LoadIcon(ghInstance, MAKEINTRESOURCE(IDI_APP_ICON));
            SendMessage (hDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon);

            SetWindowText(hDlg, _T("IntellectualHeaven(R) CrashDoctor"));

            CenterDialog(hDlg);
            pRecoveryHandler->InitInstance(hDlg, GetDlgItem(hDlg, IDC_LIST_STATUS));
            return TRUE;
        }
        case WM_COMMAND:
        {
            switch(wParam)
            {
                case IDC_BTN_TERMINATE:
                {
                    pRecoveryHandler->ExitInstance();
                    return TRUE;
                }
                case IDC_BTN_CLOSE:
                {
                    EndDialog(hDlg, IDC_BTN_CLOSE);
                    return TRUE;
                }
            }

            break;
        }
        case WM_NOTIFY:
        {
            LPNMHDR pNM = (LPNMHDR)lParam;

            if(pNM->hwndFrom == GetDlgItem(hDlg, IDC_LIST_STATUS))
            {
                switch(pNM->code)
                {
                    case NM_CUSTOMDRAW:
                    {
                        LPNMLVCUSTOMDRAW pCD = (LPNMLVCUSTOMDRAW)lParam;
                        SetWindowLong(
                                    hDlg,
                                    DWLP_MSGRESULT,
                                    (LONG)pRecoveryHandler->HandleCustomDraw(pCD));
                        return TRUE;
                    }
                }
            }
            break;
        }
    }

    return FALSE;
}
Exemplo n.º 27
0
/**************************************************************************
*
* FUNCTION NAME: ProcessRegisterDialog
*
* DESCRIPTION:
*
*
* INPUT PARAMETERS:
*     None.
*
* OUTPUT PARAMETERS:
*     None.
*
**************************************************************************/
MRESULT EXPENTRY ProcessRegisterDialog (HWND hwnd, 
                                    	 ULONG msg,
                                    	 MPARAM mp1, 
                                    	 MPARAM mp2)
{
	CHAR szID[50];

   switch (msg)
   {
      case WM_INITDLG :
		   /* Center the dialog box in the frame window of the parent */
			CenterDialog (hwnd);
         return (0);

      case WM_COMMAND :
         switch (SHORT1FROMMP (mp1))
         {
            case DID_OK:
				   WinQueryDlgItemText (hwnd, REG_NAME_ID, 
														  REGISTER_NAME_LEN, gszRegName);
				   WinQueryDlgItemText (hwnd, REG_ID_ID, sizeof(szID), szID);
					if (CheckPassword (gszRegName, szID))
					{
						/* The password is cool!  Save the settings now */
						WinDlgBox (HWND_DESKTOP, hwndDefClient, 
										  (PFNWP) ProcessProdInfoDialog,
										  0L, CONGRATS_DLG_ID, NULL);
						gfRegistered = TRUE;
						WriteIniFile ();

						/* Disable the register menu item now we're registered */
   					WinEnableMenuItem (hwndMenu, MENU_REGISTER_ID, !gfRegistered);

               	WinDismissDlg (hwnd, DID_OK);
					}
					else
					{
						WinDlgBox (HWND_DESKTOP, hwndDefClient, 
										  (PFNWP) ProcessProdInfoDialog,
										  0L, SORRY_DLG_ID, NULL);
					}
               return (0);

            case DID_CANCEL:
				   /* Dismiss the dialog without saving the values */
               WinDismissDlg (hwnd, DID_CANCEL);
               return (0);

			   case DID_HELP:
				   /* Display the keys help panel */
    				WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP,
                            MPFROM2SHORT(PANEL_REGISTER, NULL), 
									 MPFROMSHORT(HM_RESOURCEID));
               return (0);

            default:
               break;
         }
			break;

      default:
		   break;
   }

   return (WinDefDlgProc (hwnd, msg, mp1, mp2));
}
Exemplo n.º 28
0
INT_PTR
CALLBACK
HandleCrashDlgProc(
    HWND    hDlg,
    UINT    msg,
    WPARAM  wParam,
    LPARAM  lParam)
/*++

Routine Description:

    Dialog box used to ask user what action he wants to take when an application
    crashes.

Arguments:

    Refer to DialogProc in MSDN

Returns:

    TRUE - Message Handled
    FALSE - Message not handled

--*/
{
    static PROC_DBG_DATA sProcDbgData;

    switch(msg)
    {
        case WM_INITDIALOG:
        {
            //
            // Insert *specific* dialog initialization code here.
            // lParam can contain information required for initialization.
            //

            //
            // Set dialog and application Icon
            //
            HICON hIcon = LoadIcon(ghInstance, MAKEINTRESOURCE(IDI_APP_ICON_SM));
            SendMessage (hDlg, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon);
            hIcon = LoadIcon(ghInstance, MAKEINTRESOURCE(IDI_APP_ICON));
            SendMessage (hDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon);

            SetWindowText(hDlg, _T("IntellectualHeaven(R) CrashDoctor"));

            //
            // Set list control properties
            //
            HWND hListCtrl;
            hListCtrl = GetDlgItem(hDlg, IDC_LIST_DEBUGGER);
            ListView_SetExtendedListViewStyle(
                                        hListCtrl,
                                        LVS_EX_FULLROWSELECT);

            ListView_SetTextColor(  hListCtrl,
                                    RGB(0, 0, 255));

            LVCOLUMN lvColumn;
            lvColumn.mask = LVCF_TEXT | LVCF_WIDTH;

            lvColumn.cx         = 260;
            lvColumn.pszText    = _T(" Debuggers Available");

            ListView_InsertColumn(  hListCtrl,
                                    0,
                                    &lvColumn);

            CenterDialog(hDlg);

            PPROC_DBG_DATA procDbgData  = (PPROC_DBG_DATA)lParam;

            //
            // Store the PROC_DBG_DATA, it will be needed later
            //
            sProcDbgData = *procDbgData;


            // Find the process given in PROC_DBG_DATA
            DWORD processId = sProcDbgData.processId;

            IHU_PROCESS_INFO            processInfo;
            IHU_PROCESS_LIST        processList;
            IHU_PROCESS_LIST_ITER   processListIter;
            bool                        processFound = false;

            IhuGetProcessList(processList);

            for (   processListIter = processList.begin();
                    processListIter != processList.end();
                    ++processListIter)
            {
                processInfo = *processListIter;
                if (processId == processInfo.mProcessId)
                {
                    processFound = true;
                    break;
                }
            }

            //
            // Set process name and image
            //
            if (processFound)
            {
                SetWindowText(
                        GetDlgItem(hDlg, IDC_EDIT_PROCESS_NAME),
                        processInfo.mBinaryName.c_str());

                hIcon = NULL;

                IhuGetFileIcon(
                            processInfo.mBinaryName,
                            hIcon);

                if (hIcon)
                {
                    SendMessage(
                        GetDlgItem(hDlg, IDC_ICON_PROCESS),
                        STM_SETICON,
                        (WPARAM)hIcon,
                        0);
                }
            }
            else
            {
                SetWindowText(
                        GetDlgItem(hDlg, IDC_EDIT_PROCESS_NAME),
                        _T("<Unknown Process>"));
                //
                // To-Do!!!
                // This should *NEVER* happen. How to handle this?
                //
            }


            //
            // Add debugger list to the list ctrl
            //
            AddDebuggersToListCtrl(
                            hListCtrl);

            return TRUE;
        }
        case WM_COMMAND:
        {
            switch(wParam)
            {
                case IDC_BTN_RECOVER:
                {
                    EndDialog(hDlg, IDC_BTN_RECOVER);
                    return TRUE;
                }
                case IDC_BTN_TERMINATE:
                {
                    EndDialog(hDlg, IDC_BTN_TERMINATE);
                    return TRUE;
                }
                case IDC_BTN_DEBUG:
                {
                    HWND hListCtrl = GetDlgItem(hDlg, IDC_LIST_DEBUGGER);
                    int nSelectedItem = ListView_GetSelectionMark(hListCtrl);

                    if (nSelectedItem >= 0)
                    {
                        TCHAR debugCmdFormat[MAX_PATH] = {0};

                        LVITEM lvItem       = {0};
                        lvItem.mask         = LVIF_TEXT;
                        lvItem.iItem        = nSelectedItem;
                        lvItem.iSubItem     = 0;
                        lvItem.pszText      = debugCmdFormat;
                        lvItem.cchTextMax   = MAX_PATH;

                        if (ListView_GetItem(hListCtrl, &lvItem))
                        {
                            if (_tcslen(debugCmdFormat) > 0)
                            {
                                TCHAR launchDebuggerCmd[MAX_PATH * 2] = {0};
                                _stprintf(  launchDebuggerCmd,
                                            debugCmdFormat,
                                            sProcDbgData.processId,
                                            sProcDbgData.eventHandle);

                                STARTUPINFO         startupInfo;
                                PROCESS_INFORMATION procInfo;

                                ZeroMemory(&startupInfo, sizeof(startupInfo));
                                startupInfo.cb = sizeof(startupInfo);

                                ZeroMemory(&procInfo, sizeof(procInfo));

                                BOOL bResult = CreateProcess(
                                                    NULL,
                                                    launchDebuggerCmd,
                                                    NULL,
                                                    NULL,
                                                    TRUE,
                                                    0,
                                                    NULL,
                                                    NULL,
                                                    &startupInfo,
                                                    &procInfo);


                                if (!bResult)
                                {
                                    cdHandleError(
                                            hDlg,
                                            GetLastError(),
                                            _T("Unable to launch debugger."));
                                }
                                else
                                {
                                    ShowWindow(hDlg, SW_HIDE);
                                    if (sProcDbgData.eventHandle)
                                    {
                                        //
                                        // wait till either the actual debugger dies or it sets the event
                                        // This wait is necessary because if we exit before the debugger
                                        // got attached to the target. The target dies because it thinks
                                        // we are the debugger.
                                        //
                                        HANDLE waitHandle[2];
                                        waitHandle[0] = sProcDbgData.eventHandle;
                                        waitHandle[1] = procInfo.hProcess;
                                        WaitForMultipleObjects(2, (const HANDLE *)&waitHandle, FALSE, INFINITE);
                                    }
                                    else
                                    {
                                        //
                                        // wait till either the actual debugger dies or 10 seconds are over
                                        // This wait is necessary because if we exit before the debugger
                                        // got attached to the target. The target dies because it thinks
                                        // we are the debugger.
                                        //
                                        WaitForSingleObject(procInfo.hProcess, 10000);
                                    }

                                    EndDialog(hDlg, IDC_BTN_DEBUG);
                                    return FALSE;
                                }
                            }
                        }
                    }

                    break;
                }
                case IDC_BTN_ADD_DEBUGGER:
                {
                    TCHAR tempFileName[MAX_PATH];
                    tempFileName[0] = 0;

                    OPENFILENAME ofn = {0};

                    ofn.lStructSize     = OPENFILENAME_SIZE_VERSION_400;
                    ofn.hwndOwner       = hDlg;
                    ofn.hInstance       = ghInstance;
                    ofn.lpstrFilter     = _T("Executable (*.exe)\0*.exe\0\0");
                    ofn.lpstrFile       = tempFileName;
                    ofn.nMaxFile        = MAX_PATH;
                    ofn.lpstrTitle      = _T("Select a debugger");
                    ofn.Flags           = OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_PATHMUSTEXIST;

                    if (GetOpenFileName(&ofn))
                    {
                        DEBUGGER_INFO debuggerInfo;
                        debuggerInfo.debuggerPath   = ofn.lpstrFile;
                        debuggerInfo.cmdLine        = _T("-p %ld -e %ld");

                        DialogBoxParam(
                                    ghInstance,
                                    MAKEINTRESOURCE(IDD_DIALOG_ADD_DEBUGGER),
                                    hDlg,
                                    (DLGPROC)DebuggerDataDlgProc,
                                    (LPARAM)&debuggerInfo);

                        tstring debuggerCmd = _T("\"") + debuggerInfo.debuggerPath + _T("\" ") + debuggerInfo.cmdLine;
                        AddDebuggerToRegistry(hDlg, debuggerCmd);
                        AddDebuggersToListCtrl(GetDlgItem(hDlg, IDC_LIST_DEBUGGER));
                    }

                    break;
                }
                case IDC_BTN_MODIFY_DEBUGGER:
                {
                    HWND hListCtrl = GetDlgItem(hDlg, IDC_LIST_DEBUGGER);
                    int nSelectedItem = ListView_GetSelectionMark(hListCtrl);

                    if (nSelectedItem >= 0)
                    {
                        TCHAR debugCmdLine[MAX_PATH] = {0};

                        LVITEM lvItem       = {0};
                        lvItem.mask         = LVIF_TEXT | LVIF_PARAM;
                        lvItem.iItem        = nSelectedItem;
                        lvItem.iSubItem     = 0;
                        lvItem.pszText      = debugCmdLine;
                        lvItem.cchTextMax   = MAX_PATH;

                        if (ListView_GetItem(hListCtrl, &lvItem))
                        {
                            LPARAM regIndex = lvItem.lParam;

                            if (_tcslen(debugCmdLine) > 0)
                            {
                                DEBUGGER_INFO debuggerInfo;
                                debuggerInfo.cmdLine = debugCmdLine;

                                DialogBoxParam(
                                            ghInstance,
                                            MAKEINTRESOURCE(IDD_DIALOG_MODIFY_DEBUGGER),
                                            hDlg,
                                            (DLGPROC)DebuggerDataDlgProc,
                                            (LPARAM)&debuggerInfo);

                                if (_tcscmp(debugCmdLine, debuggerInfo.cmdLine.c_str()) != 0)
                                {
                                    //
                                    // Modify the particular registry entry
                                    //
                                    TCHAR valueName[32];
                                    _stprintf(valueName, _T("Debugger%02d"), regIndex);

                                    int nReturnValue        = 0;
                                    HKEY hAppDebuggerKey    = NULL;


                                    nReturnValue = RegOpenKey(
                                                            HKEY_LOCAL_MACHINE,
                                                            REG_APP_ROOT REG_APP_DEBUGGERS,
                                                            &hAppDebuggerKey);

                                    if (hAppDebuggerKey)
                                    {
                                        if (RegSetValueEx(
                                                    hAppDebuggerKey,
                                                    valueName,
                                                    0,
                                                    REG_SZ,
                                                    (LPBYTE)debuggerInfo.cmdLine.c_str(),
                                                    (DWORD)(debuggerInfo.cmdLine.length() * sizeof(TCHAR))) != ERROR_SUCCESS)
                                        {
                                            cdHandleError(
                                                    hDlg,
                                                    GetLastError(),
                                                    _T("Modify Debugger Failed. Unable to update the registry key."));
                                        }

                                        RegCloseKey(hAppDebuggerKey);

                                        AddDebuggersToListCtrl(GetDlgItem(hDlg, IDC_LIST_DEBUGGER));
                                    }
                                    else
                                    {
                                        cdHandleError(
                                                    hDlg,
                                                    GetLastError(),
                                                    _T("Modify Debugger Failed. Unable to open required registry key."));

                                    }
                                }
                            }
                        }
                    }

                    break;
                }
                case IDC_BTN_DELETE_DEBUGGER:
                {
                    HWND hListCtrl = GetDlgItem(hDlg, IDC_LIST_DEBUGGER);
                    int nSelectedItem = ListView_GetSelectionMark(hListCtrl);

                    if (nSelectedItem >= 0)
                    {
                        TCHAR debugCmdLine[MAX_PATH] = {0};

                        LVITEM lvItem       = {0};
                        lvItem.mask         = LVIF_TEXT | LVIF_PARAM;
                        lvItem.iItem        = nSelectedItem;
                        lvItem.iSubItem     = 0;
                        lvItem.pszText      = debugCmdLine;
                        lvItem.cchTextMax   = MAX_PATH;

                        if (ListView_GetItem(hListCtrl, &lvItem))
                        {
                            LPARAM regIndex = lvItem.lParam;

                            //
                            // Modify the particular registry entry
                            //
                            TCHAR valueName[32];
                            _stprintf(valueName, _T("Debugger%02d"), regIndex);

                            int nReturnValue        = 0;
                            HKEY hAppDebuggerKey    = NULL;


                            nReturnValue = RegOpenKey(
                                                    HKEY_LOCAL_MACHINE,
                                                    REG_APP_ROOT REG_APP_DEBUGGERS,
                                                    &hAppDebuggerKey);

                            if (hAppDebuggerKey)
                            {
                                if (RegDeleteValue(
                                            hAppDebuggerKey,
                                            valueName) != ERROR_SUCCESS)
                                {
                                    cdHandleError(
                                            hDlg,
                                            GetLastError(),
                                            _T("Delete Debugger Failed. Unable to delete the registry key."));
                                }

                                RegCloseKey(hAppDebuggerKey);

                                AddDebuggersToListCtrl(GetDlgItem(hDlg, IDC_LIST_DEBUGGER));
                            }
                            else
                            {
                                cdHandleError(
                                            hDlg,
                                            GetLastError(),
                                            _T("Delete Debugger Failed. Unable to open required registry key."));

                            }
                        }
                    }

                    break;
                }
                //
                // Don't allow closing from the title bar button.
                //
                /*
                case IDCANCEL:
                {
                    EndDialog(hDlg, IDCANCEL);
                    return TRUE;
                }
                */
            }

            break;
        }
        case WM_CTLCOLORSTATIC:
        {
            HDC hdc = (HDC)wParam;
            HWND hwndCtl = (HWND)lParam;

            if (hwndCtl == GetDlgItem(hDlg, IDC_EDIT_PROCESS_NAME))
            {
                if (SetTextColor(hdc, RGB(255, 0, 0)) == CLR_INVALID)
                {
                    cdHandleError(hDlg, GetLastError(), _T("Failed to set control color"));
                    break;
                }
                SetBkMode(hdc, TRANSPARENT);
                SetBkColor(hdc, GetSysColor(COLOR_WINDOW));
                SelectObject(hdc, GetSysColorBrush(COLOR_WINDOW));
                return TRUE;
            }

            break;
        }
        case WM_DESTROY:
        {
            return TRUE;
        }
        case WM_CLOSE:
        {
            break;
        }
    }

    //
    // Not handled by us
    //
    return FALSE;
}
Exemplo n.º 29
0
/**************************************************************************
*
* FUNCTION NAME: ProcessUnregisteredDialog
*
* DESCRIPTION:
*
*
* INPUT PARAMETERS:
*     None.
*
* OUTPUT PARAMETERS:
*     None.
*
**************************************************************************/
MRESULT EXPENTRY ProcessUnregisteredDialog (HWND hwnd, 
                                            ULONG msg,
                                            MPARAM mp1, 
                                            MPARAM mp2)
{
   /* Array to track the click boxes */
   static CBOXES aCBoxes[] = {{UNREG_CB0, FALSE},
										{UNREG_CB1, FALSE},
										{UNREG_CB2, FALSE},
										{UNREG_CB3, FALSE},
										{UNREG_CB4, FALSE},
										{UNREG_CB5, FALSE},
										{UNREG_CB6, FALSE},
										{UNREG_CB7, FALSE},
										{UNREG_CB8, FALSE},
										{UNREG_CB9, FALSE}};
	#define NUM_CBOXES (sizeof(aCBoxes)/sizeof(CBOXES))

	static USHORT usClicked = 0;
	INT           i;

   switch (msg)
   {
		case WM_INITDLG:
			CenterDialog (hwnd);
         return (0);

      case WM_CONTROL :
         switch (SHORT1FROMMP (mp1))
         {
			   case UNREG_CB0:
			   case UNREG_CB1:
			   case UNREG_CB2:
			   case UNREG_CB3:
			   case UNREG_CB4:
			   case UNREG_CB5:
			   case UNREG_CB6:
			   case UNREG_CB7:
			   case UNREG_CB8:
			   case UNREG_CB9:
					/* Find the entry in the array for this cbox */
				   for (i = 0;  i < NUM_CBOXES; i++)
					{
						if (aCBoxes[i].ulID == SHORT1FROMMP (mp1))
						{
						   break;
						}
					}

					if (!aCBoxes[i].fClicked)
					{
						aCBoxes[i].fClicked = TRUE;
						usClicked++;
					}
					else
					{
						aCBoxes[i].fClicked = FALSE;
						usClicked--;
					}
				   break;

				default:
               return (0);
         }
			break;

      case WM_COMMAND :
         switch (SHORT1FROMMP (mp1))
         {
            case UNREG_OK:
				   if (usClicked == NUM_CBOXES)
					{
               	WinDismissDlg (hwnd, DID_OK);
					}
               return (0);

			   case DID_HELP:
				   /* Display the keys help panel */
    				WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP,
                            MPFROM2SHORT(PANEL_REGISTER, NULL), 
									 MPFROMSHORT(HM_RESOURCEID));
               return (0);

            default:
               return (0);
         }
			break;

      default:
		   break;
   }

   return (WinDefDlgProc (hwnd, msg, mp1, mp2));
}
Exemplo n.º 30
0
INT_PTR
CALLBACK
AboutDlgProc(
    HWND hDlg,
    UINT msg,
    WPARAM wParam,
    LPARAM lParam)
/*++

Routine Description:

dialog box to show information about YahDecode

Returns:

TRUE - Message handled by the dialog proc
FALSE - Message not handled

--*/
{
    static HFONT hFontNormal = NULL;
    static bool linkHigh = false;
    int result = 0;

    switch (msg)
    {
    case WM_INITDIALOG:
    {
        HICON hIcon = LoadIcon(ghInstance, MAKEINTRESOURCE(IDI_APP_ICON_SM));
        SendMessage(hDlg, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIcon);
        SendMessage(hDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon);
        CenterDialog(hDlg);

        if (hFontNormal == NULL)
        {
            hFontNormal = CreateFont(
                12, 0, 0, 0, FW_BOLD,
                FALSE, FALSE, FALSE,
                ANSI_CHARSET,
                OUT_DEFAULT_PRECIS,
                CLIP_DEFAULT_PRECIS,
                DEFAULT_QUALITY,
                DEFAULT_PITCH | FW_DONTCARE,
                _T("Arial"));
        }

        SendDlgItemMessage(
            hDlg,
            IDC_COPYRIGHTWARNING,
            WM_SETFONT,
            (WPARAM)hFontNormal,
            NULL);

        SetDlgItemText(
            hDlg,
            IDC_COPYRIGHTWARNING,
            L"Warning: This computer program is a free program. It is "
            L"distributed under the terms of BSD License as published "
            L"by IntellectualHeaven. For a copy of this license, "
            L" write to [email protected]");

        linkHigh = false;

        break;
    }
#if 0
    case WM_CTLCOLORDLG:
    {
        return (BOOL)GetSysColorBrush(COLOR_WINDOW);
    }
#endif
    case WM_CTLCOLORSTATIC:
    {
        HDC hdc = (HDC)wParam;

        if (GetDlgItem(hDlg, IDC_STATIC_LINK) == (HWND)lParam)
        {
            if (linkHigh)
            {
                if (SetTextColor(hdc, RGB(200, 100, 0)) == CLR_INVALID)
                {
                    cdHandleError(hDlg, GetLastError(), _T("Failed to set control color"));
                    break;
                }
            }
            else
            {
                if (SetTextColor(hdc, RGB(0, 0, 255)) == CLR_INVALID)
                {
                    cdHandleError(hDlg, GetLastError(), _T("Failed to set control color"));
                    break;
                }
            }

            SetBkMode(hdc, TRANSPARENT);
            return (BOOL)GetSysColorBrush(COLOR_BTNFACE);
        }

        if (GetDlgItem(hDlg, IDC_COPYRIGHTWARNING) == (HWND)lParam)
        {
            if (SetTextColor(hdc, RGB(64, 64, 64)) == CLR_INVALID)
            {
                cdHandleError(hDlg, GetLastError(), _T("Failed to set control color"));
                break;
            }

            SetBkMode(hdc, TRANSPARENT);
            return (BOOL)GetSysColorBrush(COLOR_BTNFACE);
        }

        break;
    }
    case WM_MOUSEMOVE:
    {
        short xbase = 120;
        short ybase = 66;
        short x = (short)LOWORD(lParam);
        short y = (short)HIWORD(lParam);
        if (x >= xbase && x <= (xbase + 178) && y >= ybase && y <= (ybase + 12))
        {
            if (!linkHigh)
            {
                linkHigh = true;
                InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_LINK), NULL, FALSE);
            }

            SetCursor(LoadCursor(NULL, IDC_HAND));
        }
        else
        {
            if (linkHigh)
            {
                linkHigh = false;
                InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_LINK), NULL, FALSE);
            }
            SetCursor(LoadCursor(NULL, IDC_ARROW));
        }

        return 0;
    }
    case WM_LBUTTONDOWN:
    {
        if (linkHigh)
        {
            ShellExecute(
                NULL,
                NULL,
                _T("http://www.intellectualheaven.com"),
                NULL,
                NULL,
                SW_SHOW | SW_MAXIMIZE);

            return 0;
        }

        break;
    }
    case WM_COMMAND:
    {
        switch (wParam)
        {
        case IDOK:
        {
            EndDialog(hDlg, IDOK);
            return TRUE;
        }
        case IDCANCEL:
        {
            EndDialog(hDlg, IDCANCEL);
            return TRUE;
        }
        }

        break;
    }
    }

    return FALSE;
}