?? main.c
字號:
// Written by Dr. William J. Blanke, November 2008
// Licensed under The Code Project Open License (CPOL)
#include "LogoHelper.h"
#include "resource.h"
#define APPNAME TEXT("Logo Helper")
HINSTANCE g_hinst;
typedef struct
{
SHACTIVATEINFO sai;
HWND hwndCombo;
HWND hwndEdit;
int iEnable;
} LOGODATA;
void OnSize (HWND hWnd,LOGODATA *ld)
{
RECT rc,rcItem;
GetClientRect(hWnd,&rc);
GetWindowRect (ld->hwndCombo, &rcItem);
MapWindowPoints (NULL, hWnd, (LPPOINT)&rcItem, 2);
MoveWindow (ld->hwndCombo,rcItem.left,rcItem.top,
(rc.right-rcItem.left)-rcItem.left,(rc.bottom-rcItem.left)-rcItem.top,TRUE);
GetWindowRect (ld->hwndEdit, &rcItem);
MapWindowPoints (NULL, hWnd, (LPPOINT)&rcItem, 2);
MoveWindow (ld->hwndEdit,rcItem.left,rcItem.top,
(rc.right-rcItem.left)-rcItem.left,(rc.bottom-rcItem.left)-rcItem.top,TRUE);
}
BOOL CALLBACK DlgProc (HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
LOGODATA *ld;
ld=(LOGODATA *)GetWindowLong (hWnd, GWL_USERDATA);
switch (wMsg)
{
case WM_INITDIALOG:
{
SHMENUBARINFO mbi;
SHINITDLGINFO shidi;
SetWindowLong(hWnd,GWL_USERDATA,lParam);
ld=(LOGODATA *)lParam;
ld->hwndEdit=GetDlgItem(hWnd,IDC_EDIT1);
ld->hwndCombo=GetDlgItem(hWnd,IDC_COMBO1);
memset(&shidi,0x00,sizeof(SHINITDLGINFO));
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN;
shidi.hDlg = hWnd;
SHInitDialog (&shidi);
memset(&mbi, 0x00, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hWnd;
mbi.nToolBarId = IDR_MENU1;
mbi.dwFlags = SHCMBF_HMENU;
mbi.hInstRes = g_hinst;
SHCreateMenuBar(&mbi);
SetWindowText(hWnd,APPNAME);
SetWindowText(ld->hwndEdit,
TEXT("Try deleting this text with the back ")
TEXT("button on non-touchscreen devices. ")
TEXT("The combobox or spinner control (depending ")
TEXT("on platform) above toggles whether the ")
TEXT("edit control is active and thus how the ")
TEXT("back button behaves. Have fun!"));
LH_InitSpinCombo(ld->hwndCombo);
SendMessage (ld->hwndCombo, CB_ADDSTRING, 0, (LPARAM)TEXT("Edit Control Disabled"));
ld->iEnable=SendMessage (ld->hwndCombo, CB_ADDSTRING, 0, (LPARAM)TEXT("Edit Control Enabled"));
SendMessage (ld->hwndCombo, CB_SETCURSEL, (WPARAM)ld->iEnable, (LPARAM)0);
LH_SIPCreate(hWnd,&(ld->sai));
LH_BackKeyBehavior(hWnd,TRUE); // There is an edit control
return TRUE;
}
case WM_ACTIVATE:
LH_SIPActivate(hWnd, wParam, lParam, &(ld->sai));
break;
case WM_SETTINGCHANGE:
LH_SIPSettingChange(hWnd, wParam, lParam, &(ld->sai));
break;
case WM_HOTKEY:
LH_BackKeyHotKey(hWnd,wMsg,wParam,lParam);
break;
case WM_SIZE:
OnSize(hWnd,ld);
break;
case WM_COMMAND:
{
switch (LOWORD (wParam))
{
case IDC_COMBO1:
{
if(HIWORD(wParam)==CBN_SELCHANGE)
{
BOOL bShowEdit;
bShowEdit=(SendMessage(ld->hwndCombo,CB_GETCURSEL,0,0)==ld->iEnable);
ShowWindow(ld->hwndEdit,bShowEdit?SW_SHOW:SW_HIDE);
LH_BackKeyBehavior(hWnd,bShowEdit);
}
break;
}
case IDC_EXIT: // From our menubar
EndDialog(hWnd, TRUE);
break;
case IDCANCEL: // Via Smartphone Back Button
SHNavigateBack();
break;
}
break;
}
}
return FALSE;
}
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPWSTR lpCmdLine, int nCmdShow)
{
LOGODATA ld;
HANDLE hSem;
hSem = CreateSemaphore (NULL, 0, 1, APPNAME);
if ((hSem != NULL) && (GetLastError() == ERROR_ALREADY_EXISTS))
{
HWND hWndExisting;
CloseHandle(hSem);
hWndExisting = FindWindow (NULL, APPNAME);
if (hWndExisting)
SetForegroundWindow ((HWND)(((ULONG)hWndExisting) | 0x01));
return TRUE;
}
memset(&ld,0x00,sizeof(LOGODATA));
g_hinst=hInstance;
InitCommonControls();
return DialogBoxParam (g_hinst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DlgProc, (LPARAM)&ld);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -