本文整理汇总了C++中SetWindowLong函数的典型用法代码示例。如果您正苦于以下问题:C++ SetWindowLong函数的具体用法?C++ SetWindowLong怎么用?C++ SetWindowLong使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetWindowLong函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFileName
//.........这里部分代码省略.........
UpdateWindow( mh );
dchandle = GetDC( mh );
GetTextMetrics( dchandle, &tm );
avgx = AvgXChar( tm );
avgy = AvgYChar( tm );
ReleaseDC( mh, dchandle );
mainWindow = mh;
xp = 32;
yp = y/8-10;
ys = avgy+avgy/2;
xs = (47+1) * avgx+avgx/2;
win = CreateWindow(
"STATIC", /* class */
"Sampler Options:", /* caption */
WS_CHILD | ES_LEFT,
xp+(14*avgx)-6, /* init. x pos */
yp-3-avgy*3/2, /* init. y pos */
16*avgx, /* init. x size */
ys, /* init. y size */
mh, /* parent window */
NULL, /* child id */
inst, /* program handle */
NULL /* create parms */
);
ShowWindow( win, SW_SHOWNORMAL );
UpdateWindow( win );
win = CreateWindow(
"EDIT", /* class */
NULL, /* caption */
WS_CHILD | ES_LEFT | WS_BORDER | ES_AUTOHSCROLL,
xp+7, /* init. x pos */
yp, /* init. y pos */
xs, /* init. x size */
ys, /* init. y size */
mh, /* parent window */
(HMENU)EDIT_ID, /* child id */
inst, /* program handle */
NULL /* create parms */
);
if( win == NULL ) {
return( FALSE );
}
editChild = win;
ShowWindow( win, SW_SHOWNORMAL );
UpdateWindow( win );
oldClassProc = (FARPROC) GetWindowLong( editChild, GWL_WNDPROC );
SetWindowLong( editChild, GWL_WNDPROC, (LONG) SubClassProc );
win = CreateWindow(
"BUTTON", /* class */
"&Select File...", /* caption */
WS_CHILD | BS_PUSHBUTTON,
xp+(6*avgx)-6, /* init. x pos */
yp+avgy*3, /* init. y pos */
16*avgx, /* init. x size */
avgy+avgy/2, /* init. y size */
mh, /* parent window */
(HMENU)PUSH_GETFILES_ID,/* child id */
inst, /* program handle */
NULL /* create parms */
);
ShowWindow( win, SW_SHOWNORMAL );
UpdateWindow( win );
win = CreateWindow(
"BUTTON", /* class */
"S&tart Sampling", /* caption */
WS_CHILD | BS_PUSHBUTTON,
xp+(29*avgx)-6, /* init. x pos */
yp+avgy*3, /* init. y pos */
16*avgx, /* init. x size */
avgy+avgy/2, /* init. y size */
mh, /* parent window */
(HMENU)PUSH_OK_ID, /* child id */
inst, /* program handle */
NULL /* create parms */
);
ShowWindow( win, SW_SHOWNORMAL );
UpdateWindow( win );
SetFocus( editChild );
while( GetMessage( &msg, NULL, 0, 0 ) ) {
if( !TranslateAccelerator( mainWindow, accel, &msg ) ) {
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
return( canContinue );
} /* GetFileName */
示例2: SetWMode
void SetWMode(int width, int height, bool state)
{
// Compatibility for Xen W-Mode
if ( ghMainWnd && !(GetWindowLong(ghMainWnd, GWL_STYLE) & WS_SYSMENU) )
return;
if ( !isCorrectVersion )
return;
if ( state )
{
wmode = true;
if ( !ghMainWnd )
return;
// Call the DirectDraw destructor
DDrawDestroy();
InitializeWModeBitmap(BW::BWDATA::GameScreenBuffer.width(), BW::BWDATA::GameScreenBuffer.height());
// Hack to enable drawing in Broodwar
BW::BWDATA::PrimarySurface = (LPDIRECTDRAWSURFACE)1;
const int shift = gdwProcNum > 1 ? 32 : 0;
POINT pos = { windowRect.left + shift, windowRect.top + shift };
// Change the window settings
SetWindowLong(ghMainWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
SetWindowPos(ghMainWnd, HWND_NOTOPMOST, pos.x, pos.y, width, height, SWP_SHOWWINDOW);
ShowWindow(ghMainWnd, SW_RESTORE);
SIZE border;
GetBorderSize(ghMainWnd, &border);
int w = width + border.cx;
int h = height + border.cy;
int cx = GetSystemMetrics(SM_CXFULLSCREEN);
int cy = GetSystemMetrics(SM_CYFULLSCREEN);
while ( pos.x < 0 )
pos.x = 0;
while ( pos.y < 0 )
pos.y = 0;
if ( pos.y + h >= cy )
{
if (gdwProcNum > 1)
pos.y -= cy - h;
else
pos.y = cy - h;
}
if ( pos.x + w >= cx )
{
if (gdwProcNum > 1)
pos.x -= cx - w;
else
pos.x = cx - w;
}
MoveWindow(ghMainWnd, pos.x, pos.y, w, h, TRUE);
SetCursor(NULL);
SetCursorShowState(false);
SetDIBColorTable(hdcMem, 0, 256, wmodebmp.bmiColors);
WritePrivateProfileStringA("window", "windowed", "ON", configPath.c_str());
}
else
{
wmode = false;
BW::BWDATA::PrimarySurface = NULL;
if ( hdcMem )
DeleteDC(hdcMem);
hdcMem = NULL;
if (ghMainWnd)
{
SetWindowLong(ghMainWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE | WS_SYSMENU);
SetWindowPos(ghMainWnd, HWND_TOPMOST, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW);
SetCursor(NULL);
SetCursorShowState(false);
SetFocus(ghMainWnd);
}
DDrawDestroy();
DDrawInitialize(width, height);
WritePrivateProfileStringA("window", "windowed", "OFF", configPath.c_str());
}
}
示例3: InitRunDlg
void InitRunDlg(HWND hDlg, LPRUNDLG_DATA lprd)
{
HWND hCB;
int i;
#ifdef WINNT
HANDLE hThread = NULL;
DWORD dwDummy;
#endif
if (lprd->lpszTitle)
SetWindowText(hDlg, lprd->lpszTitle);
if (lprd->lpszPrompt)
{
SetDlgItemText(hDlg, IDD_PROMPT, lprd->lpszPrompt);
}
if (lprd->hIcon)
{
Static_SetIcon(GetDlgItem(hDlg, IDD_ICON), lprd->hIcon);
}
if (lprd->dwFlags & RFD_NOBROWSE)
{
HWND hBrowse;
hBrowse = GetDlgItem(hDlg, IDD_BROWSE);
ExchangeWindowPos(hBrowse, GetDlgItem(hDlg, IDCANCEL));
ExchangeWindowPos(hBrowse, GetDlgItem(hDlg, IDOK));
ShowWindow(hBrowse, SW_HIDE);
}
if (lprd->dwFlags & RFD_NOSHOWOPEN)
{
ShowWindow(GetDlgItem(hDlg, IDD_RUNDLGOPENPROMPT), SW_HIDE);
}
#ifdef SHOWSTATES
/* Note that we need to fill this list first so that the SELCHANGE
* message sent below will do the right thing.
*/
hCB = GetDlgItem(hDlg, IDD_STATE);
for (i = 0; i < ARRAYSIZE(pnStates); ++i)
{
if (SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)(LPTSTR)szStates[i]) < 0)
{
break;
}
}
SendMessage(hCB, CB_SETCURSEL, 0, 0L);
#endif
hCB = GetDlgItem(hDlg, IDD_COMMAND);
SendMessage(hCB, CB_LIMITTEXT, MAX_PATH-1, 0L);
OpenRunDlgMRU();
if (g_hMRURunDlg)
{
int nMax;
TCHAR szCommand[MAX_PATH];
for (nMax=EnumMRUList(g_hMRURunDlg, -1, NULL, 0), i=0; i<nMax; ++i)
{
if (EnumMRUList(g_hMRURunDlg, i, szCommand, ARRAYSIZE(szCommand)) > 0)
{
PSTARTINFO pStartInfo;
/* Parse the line into the STARTINFO struct
*/
pStartInfo = ParseIniLine(szCommand);
/* The command to run goes in the combobox.
*/
if (SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)(LPTSTR)szCommand)
!= i)
{
if (pStartInfo)
{
LocalFree((HLOCAL)pStartInfo);
}
}
else
{
SendMessage(hCB, CB_SETITEMDATA, i, (LPARAM)(LPSTARTINFO)pStartInfo);
}
}
}
}
if (!(lprd->dwFlags & RFD_NODEFFILE))
{
SendMessage(hCB, CB_SETCURSEL, 0, 0L);
}
SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDD_COMMAND, CBN_SELCHANGE), (LPARAM) hCB);
SetWindowLong(hDlg, DWL_USER, (LONG)lprd);
//.........这里部分代码省略.........
示例4: OptionsProc
BOOL CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam)
{
switch(msg){
case WM_INITDIALOG:{
DWORD style;
g_opHdlg=hdlg;
bOptionsInit=TRUE;
TranslateDialogDefault(hdlg);
if(g_iButtonsCount!=DBGetContactSettingByte(NULL, PLGNAME,"ButtonsCount", 0))
{
LOGFONT logFont;
HFONT hFont;
bNeedRestart=TRUE;
EnableWindow(GetDlgItem(hdlg,IDC_BUTTONSLIST),FALSE);
EnableWindow(GetDlgItem(hdlg,IDC_BLISTADD),FALSE);
EnableWindow(GetDlgItem(hdlg,IDC_BLISTREMOVE),FALSE);
EnableWindow(GetDlgItem(hdlg,IDC_MENUTREE),FALSE);
EnableWindow(GetDlgItem(hdlg,IDC_MTREEADD),FALSE);
EnableWindow(GetDlgItem(hdlg,IDC_MTREEREMOVE),FALSE);
EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
EnableWindow(GetDlgItem(hdlg,IDC_RCLICKVALUE),FALSE);
EnableWindow(GetDlgItem(hdlg,IDC_BUTTONNAME),FALSE);
EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),FALSE);
EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
EnableWindow(GetDlgItem(hdlg,IDC_MENUNAME),FALSE);
ShowWindow(GetDlgItem(hdlg,IDC_WARNING),SW_SHOW);
hFont = (HFONT)SendMessage(GetDlgItem(hdlg, IDC_WARNING), WM_GETFONT, 0, 0);
GetObject(hFont, sizeof logFont, &logFont);
logFont.lfWeight = FW_BOLD;
hFont = CreateFontIndirect(&logFont);
SendMessage(GetDlgItem(hdlg, IDC_WARNING), WM_SETFONT, (WPARAM)hFont, 0);
break;
}
g_iOPButtonsCount=g_iButtonsCount;
hButtonsList=GetDlgItem(hdlg,IDC_BUTTONSLIST);
hMenuTree=GetDlgItem(hdlg,IDC_MENUTREE);
style = GetWindowLong(hButtonsList,GWL_STYLE);
style |=TVS_NOHSCROLL;
SetWindowLong(hButtonsList,GWL_STYLE, style);
style = GetWindowLong(hMenuTree,GWL_STYLE);
style |=TVS_NOHSCROLL;
SetWindowLong(hMenuTree,GWL_STYLE, style);
BuildButtonsList(hButtonsList);
if(!TreeView_GetCount(hButtonsList)) EnableWindow(GetDlgItem(hdlg,IDC_RCLICKVALUE),FALSE);
oldBNameProc = (WNDPROC) SetWindowLong(GetDlgItem(hdlg,IDC_BUTTONNAME), GWL_WNDPROC, (LONG) EditSubclassProc);
oldMNameProc = (WNDPROC) SetWindowLong(GetDlgItem(hdlg,IDC_MENUNAME) , GWL_WNDPROC, (LONG) EditSubclassProc);
EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),FALSE);
EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
CheckDlgButton(hdlg,IDC_RAUTOSEND,(g_bRClickAuto=DBGetContactSettingByte(NULL,PLGNAME,"RClickAuto",0)));
CheckDlgButton(hdlg,IDC_LAUTOSEND,(g_bLClickAuto=DBGetContactSettingByte(NULL,PLGNAME,"LClickAuto",0)));
CheckDlgButton(hdlg,IDC_ENABLEQUICKMENU,(g_bQuickMenu=DBGetContactSettingByte(NULL, PLGNAME,"QuickMenu", 1)));
bOptionsInit=FALSE;
}break;
case WM_LBUTTONUP:
if(drag) {
TVHITTESTINFO hti;
HTREEITEM htiAfter=NULL;
ButtonData* bd=NULL;
TVITEM tvi;
RECT rc;
BYTE height;
BOOLEAN bAsChild = FALSE;
TreeView_SetInsertMark(hMenuTree, NULL, 0 );
ReleaseCapture();
SetCursor( LoadCursor( NULL, IDC_ARROW ) );
hti.pt.x = ( SHORT )LOWORD( lparam );
hti.pt.y = ( SHORT )HIWORD( lparam );
ClientToScreen(hdlg,&hti.pt);
ScreenToClient(hMenuTree,&hti.pt);
TreeView_HitTest( hMenuTree, &hti );
if(TreeView_GetParent(hMenuTree,hti.hItem)&&TreeView_GetChild(hMenuTree,hDragItem))
break;
if(TreeView_GetChild(hMenuTree,hti.hItem)&&TreeView_GetChild(hMenuTree,hDragItem))
break;
if( hti.flags & TVHT_ABOVE ) {
htiAfter = TVI_FIRST;
}
else
if( hti.flags & ( TVHT_NOWHERE|TVHT_BELOW ) ) {
htiAfter = TVI_LAST;
}
else
//.........这里部分代码省略.........
示例5: AttachWBCoreToFrame
bool AttachWBCoreToFrame(IWBCoreControler *pWBCoreControler,IWBCoreNotifyer *pNewWBCoreNotifyer,IUIControler *pUIControler)
{
ATLASSERT( pWBCoreControler && pNewWBCoreNotifyer && pUIControler );
//先获取两个窗口的句柄
HWND hMainFrame = NULL;
HWND hCoreWnd = NULL;
pUIControler->ControlQueryQueryMainFrame( &hMainFrame );
pWBCoreControler->ControlQueryWnd(&hCoreWnd);
CRect rcClient;
pUIControler->ControlQueryClientRect(&rcClient);
::SetParent(hCoreWnd,hMainFrame);
DWORD dwStyle = GetWindowLong(hCoreWnd,GWL_STYLE);
dwStyle|=WS_CHILD;
SetWindowLong(hCoreWnd,GWL_STYLE,dwStyle);
pWBCoreControler->ControlMoveWindow(rcClient.left,rcClient.top,rcClient.Width(),rcClient.Height());
pWBCoreControler->ControlShowWindow(TRUE);
//通知新的父窗口有新的浏览器窗口插入
CString strUrl;
CString strTitle;
BOOL bCanBack;
BOOL bCanForward;
PAGEID nPageID = 0;
pWBCoreControler->ControlQueryUrl(strUrl.GetBuffer(4000),4000);
strUrl.ReleaseBuffer();
pWBCoreControler->ControlQueryTitle(strTitle.GetBuffer(200),200);
strTitle.ReleaseBuffer();
pWBCoreControler->ControlQueryBackForwardStatus(&bCanBack,&bCanForward);
pWBCoreControler->GetPageID(&nPageID);
//插入到新的通知实例中
INotifyerInstance *pNotify = dynamic_cast<INotifyerInstance *>(pNewWBCoreNotifyer);
PAGEINFO info;
info.hWnd = hCoreWnd;
info.strUrl = strUrl;
info.strTitle = strTitle;
info.pCoreControler = pWBCoreControler;
info.bCanBack = bCanBack;
info.bCanForward = bCanForward;
pNotify->InsertPage(nPageID,&info);
//修正UI显示
pUIControler->ControlAddTab(nPageID,strUrl,strTitle);
pUIControler->ControlSetFocusTab(nPageID);
pNewWBCoreNotifyer->NotifySetCurrentPage(nPageID);
//设置浏览器内核新的通知接口
pWBCoreControler->SetNotifyPtr(pNewWBCoreNotifyer);
return true;
}
示例6: LConProc
LRESULT CALLBACK LConProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HWND view;
HDC hdc;
HBRUSH hbr;
HGDIOBJ oldfont;
RECT rect;
int titlelen;
SIZE size;
LOGFONT lf;
TEXTMETRIC tm;
HINSTANCE inst = (HINSTANCE)(LONG_PTR)GetWindowLongPtr(hWnd, GWLP_HINSTANCE);
DRAWITEMSTRUCT *drawitem;
CHARFORMAT2W format;
switch (msg)
{
case WM_CREATE:
// Create game title static control
memset (&lf, 0, sizeof(lf));
hdc = GetDC (hWnd);
lf.lfHeight = -MulDiv(12, GetDeviceCaps(hdc, LOGPIXELSY), 72);
lf.lfCharSet = ANSI_CHARSET;
lf.lfWeight = FW_BOLD;
lf.lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN;
strcpy (lf.lfFaceName, "Trebuchet MS");
GameTitleFont = CreateFontIndirect (&lf);
oldfont = SelectObject (hdc, GetStockObject (DEFAULT_GUI_FONT));
GetTextMetrics (hdc, &tm);
DefaultGUIFontHeight = tm.tmHeight;
if (GameTitleFont == NULL)
{
GameTitleFontHeight = DefaultGUIFontHeight;
}
else
{
SelectObject (hdc, GameTitleFont);
GetTextMetrics (hdc, &tm);
GameTitleFontHeight = tm.tmHeight;
}
SelectObject (hdc, oldfont);
// Create log read-only edit control
view = CreateWindowEx (WS_EX_NOPARENTNOTIFY, "RichEdit20W", NULL,
WS_CHILD | WS_VISIBLE | WS_VSCROLL |
ES_LEFT | ES_MULTILINE | WS_CLIPSIBLINGS,
0, 0, 0, 0,
hWnd, NULL, inst, NULL);
HRESULT hr;
hr = GetLastError();
if (view == NULL)
{
ReleaseDC (hWnd, hdc);
return -1;
}
SendMessage (view, EM_SETREADONLY, TRUE, 0);
SendMessage (view, EM_EXLIMITTEXT, 0, 0x7FFFFFFE);
SendMessage (view, EM_SETBKGNDCOLOR, 0, RGB(70,70,70));
// Setup default font for the log.
//SendMessage (view, WM_SETFONT, (WPARAM)GetStockObject (DEFAULT_GUI_FONT), FALSE);
format.cbSize = sizeof(format);
format.dwMask = CFM_BOLD | CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_CHARSET;
format.dwEffects = 0;
format.yHeight = 200;
format.crTextColor = RGB(223,223,223);
format.bCharSet = ANSI_CHARSET;
format.bPitchAndFamily = FF_SWISS | VARIABLE_PITCH;
wcscpy(format.szFaceName, L"DejaVu Sans"); // At least I have it. :p
SendMessageW(view, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&format);
ConWindow = view;
ReleaseDC (hWnd, hdc);
view = CreateWindowEx (WS_EX_NOPARENTNOTIFY, "STATIC", NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SS_OWNERDRAW, 0, 0, 0, 0, hWnd, NULL, inst, NULL);
if (view == NULL)
{
return -1;
}
SetWindowLong (view, GWL_ID, IDC_STATIC_TITLE);
GameTitleWindow = view;
return 0;
case WM_SIZE:
if (wParam != SIZE_MAXHIDE && wParam != SIZE_MAXSHOW)
{
LayoutMainWindow (hWnd, ErrorPane);
}
return 0;
case WM_DRAWITEM:
// Draw title banner.
if (wParam == IDC_STATIC_TITLE && DoomStartupInfo.Name.IsNotEmpty())
{
const PalEntry *c;
// Draw the game title strip at the top of the window.
drawitem = (LPDRAWITEMSTRUCT)lParam;
//.........这里部分代码省略.........
示例7: set_hotkey_proc
/*
* set_hotkey_proc - ホットキー設定ウィンドウプロシージャ
*/
static BOOL CALLBACK set_hotkey_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
DATA_INFO *di;
int i;
switch (uMsg) {
case WM_INITDIALOG:
if ((di = (DATA_INFO *)lParam) == NULL) {
EndDialog(hDlg, FALSE);
break;
}
// ホットキー
i = 0;
if (di->op_modifiers & MOD_SHIFT) {
i |= HOTKEYF_SHIFT;
}
if (di->op_modifiers & MOD_CONTROL) {
i |= HOTKEYF_CONTROL;
}
if (di->op_modifiers & MOD_ALT) {
i |= HOTKEYF_ALT;
}
if (di->op_modifiers & MOD_WIN) {
CheckDlgButton(hDlg, IDC_CHECK_WIN, 1);
}
if (di->op_virtkey != 0) {
SendDlgItemMessage(hDlg, IDC_HOTKEY_ITEM, HKM_SETHOTKEY,
(WPARAM)MAKEWORD(di->op_virtkey, i), 0);
// 貼り付け
CheckDlgButton(hDlg, IDC_CHECK_PASTE, di->op_paste);
} else {
CheckDlgButton(hDlg, IDC_CHECK_PASTE, 1);
}
SetWindowLong(hDlg, GWL_USERDATA, lParam);
break;
case WM_CLOSE:
EndDialog(hDlg, FALSE);
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCANCEL:
SendMessage(hDlg, WM_CLOSE, 0, 0);
break;
case IDOK:
di = (DATA_INFO *)GetWindowLong(hDlg, GWL_USERDATA);
if (di == NULL) {
EndDialog(hDlg, FALSE);
break;
}
// ホットキー
i = SendDlgItemMessage(hDlg, IDC_HOTKEY_ITEM, HKM_GETHOTKEY, 0, 0);
di->op_virtkey = LOBYTE(i);
i = HIBYTE(i);
di->op_modifiers = ((i & HOTKEYF_SHIFT) ? MOD_SHIFT : 0) |
((i & HOTKEYF_CONTROL) ? MOD_CONTROL : 0) |
((i & HOTKEYF_ALT) ? MOD_ALT : 0);
if (IsDlgButtonChecked(hDlg, IDC_CHECK_WIN) == 1) {
di->op_modifiers |= MOD_WIN;
}
// 貼り付け
di->op_paste = IsDlgButtonChecked(hDlg, IDC_CHECK_PASTE);
EndDialog(hDlg, TRUE);
break;
}
break;
default:
return FALSE;
}
return TRUE;
}
示例8: DlgProc
LRESULT CALLBACK DlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_INITDIALOG:
{
RECT rectOwner, rectDlg, rectDiff;
GetWindowRect(GetDesktopWindow(), &rectOwner);
GetWindowRect(hwndDlg, &rectDlg);
CopyRect(&rectDiff, &rectOwner);
OffsetRect(&rectDlg, -rectDlg.left, -rectDlg.top);
OffsetRect(&rectDiff, -rectDiff.left, -rectDiff.top);
OffsetRect(&rectDiff, -rectDlg.right, -rectDlg.bottom);
SetWindowPos(hwndDlg, HWND_TOP, rectOwner.left + (rectDiff.right / 2), rectOwner.top + (rectDiff.bottom / 2), 0, 0, SWP_NOSIZE);
HWND hwndProg = GetDlgItem(hwndDlg, IDC_PROGRESS);
DWORD dwStyle = GetWindowLong(hwndProg, GWL_STYLE);
SetWindowLong(hwndProg, GWL_STYLE, dwStyle | PBS_MARQUEE);
SendMessage(hwndProg, PBM_SETMARQUEE, TRUE, 70 /* = scroll speed */);
HWND hwndOK = GetDlgItem(hwndDlg, IDC_OK);
if (silentFlag) {
RECT rectProg, rectOK;
GetWindowRect(hwndProg, &rectProg);
GetWindowRect(hwndOK, &rectOK);
POINT posProg;
posProg.x = rectProg.left;
posProg.y = rectProg.top;
ScreenToClient(hwndDlg, &posProg);
MoveWindow(hwndProg, posProg.x, posProg.y, rectOK.right - rectProg.left, rectProg.bottom - rectProg.top, TRUE);
ShowWindow(hwndOK, SW_HIDE);
} else {
EnableWindow(hwndOK, FALSE);
}
HWND hwndDetails = GetDlgItem(hwndDlg, IDC_DETAILS);
ShowWindow(hwndDetails, SW_HIDE);
LPTSTR dialogText = (LPTSTR)malloc(MAX_STRING_LENGTH * sizeof(TCHAR));
UINT titleID = (uninstallFlag ? IDS_UNINSTALL : IDS_INSTALL);
LoadString(GetModuleHandle(NULL), titleID, dialogText, MAX_STRING_LENGTH);
SetWindowText(hwndDlg, dialogText);
LoadString(GetModuleHandle(NULL), IDS_CLOSE, dialogText, MAX_STRING_LENGTH);
SetDlgItemText(hwndDlg, IDC_OK, dialogText);
LoadString(GetModuleHandle(NULL), IDS_DETAILS, dialogText, MAX_STRING_LENGTH);
SetDlgItemText(hwndDlg, IDC_DETAILS, dialogText);
LPTSTR message = (LPTSTR)malloc((2 * MAX_STRING_LENGTH + 10) * sizeof(TCHAR));
UINT loadingID = (uninstallFlag ? IDS_LOADING_U : IDS_LOADING);
LoadString(GetModuleHandle(NULL), loadingID, message, MAX_STRING_LENGTH);
loadingID = (estTime) ? IDS_TIMESPEC : IDS_TIMEUNDEF;
LoadString(GetModuleHandle(NULL), loadingID, dialogText, MAX_STRING_LENGTH);
LPTSTR time = (LPTSTR)malloc(9 * sizeof(TCHAR));
_itot(estTime, time, 10);
DWORD_PTR messageArguments[] = { (DWORD_PTR)time };
HLOCAL formattedString = NULL;
DWORD formatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY;
FormatMessage(formatFlags, dialogText, loadingID, 0, (LPTSTR)&formattedString, 0, (va_list*)messageArguments);
free(time);
_tcsncat(message, _T("\n"), 2 * MAX_STRING_LENGTH + 10);
_tcsncat(message, formattedString, 2 * MAX_STRING_LENGTH + 10);
SetDlgItemText(hwndDlg, IDC_MESSAGE, message);
LocalFree(formattedString);
free(dialogText);
free(message);
}
SetTimer(hwndDlg, IDT_TIMER1, 500, (TIMERPROC)NULL);
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
case IDCANCEL:
if (hChildProc == 0) {
EndDialog(hwndDlg, wParam);
return TRUE;
}
break;
case IDC_DETAILS: {
LPTSTR errorMsg = _tcserror(exitCode);
LPTSTR messsageFormat = (LPTSTR)malloc(MAX_STRING_LENGTH);
LoadString(NULL, IDS_ERRORCODE, messsageFormat, MAX_STRING_LENGTH);
HLOCAL messageString = NULL;
DWORD_PTR messageArguments[] = { (DWORD_PTR)exitCode, (DWORD_PTR)errorMsg };
DWORD formatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY;
FormatMessage(formatFlags, messsageFormat, IDS_ERRORCODE, 0, (LPTSTR)&messageString, 0, (va_list*)messageArguments);
//.........这里部分代码省略.........
示例9: insert_dlg_proc
LRESULT CALLBACK insert_dlg_proc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
static TABLE_WINDOW *win=0;
static HWND hlistview=0,hgrippy=0,hedit=0;
static HFONT hfont=0;
static WNDPROC origlistview=0;
if(FALSE)
{
static DWORD tick=0;
if((GetTickCount()-tick)>500)
printf("--\n");
if(hwnd==hlistview)
printf("-");
print_msg(msg,lparam,wparam,hwnd);
tick=GetTickCount();
}
if(origlistview!=0 && hwnd==hlistview){
if(msg==WM_GETDLGCODE){
return DLGC_WANTARROWS;
}
return CallWindowProc(origlistview,hwnd,msg,wparam,lparam);
}
switch(msg){
case WM_INITDIALOG:
if(lparam==0){
EndDialog(hwnd,0);
break;
}
hedit=0;
win=lparam;
hlistview=CreateWindow(WC_LISTVIEW,"",WS_TABSTOP|WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE|LVS_REPORT|LVS_SHOWSELALWAYS,
0,0,
0,0,
hwnd,
IDC_LIST1,
ghinstance,
NULL);
if(hlistview!=0){
ListView_SetExtendedListViewStyle(hlistview,LVS_EX_FULLROWSELECT);
hfont=SendMessage(win->hlistview,WM_GETFONT,0,0);
if(hfont!=0)
SendMessage(hlistview,WM_SETFONT,hfont,0);
populate_insert_dlg(hwnd,hlistview,win);
ListView_SetItemState(hlistview,0,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
origlistview=SetWindowLong(hlistview,GWL_WNDPROC,(LONG)insert_dlg_proc);
}
set_title(hwnd,win);
hgrippy=create_grippy(hwnd);
resize_insert_dlg(hwnd);
break;
case WM_NOTIFY:
{
NMHDR *nmhdr=lparam;
if(nmhdr!=0){
switch(nmhdr->code){
case NM_DBLCLK:
if(hedit==0 && nmhdr->hwndFrom==hlistview)
SendMessage(hwnd,WM_COMMAND,IDOK,0);
break;
case LVN_COLUMNCLICK:
{
static sort_dir=0;
NMLISTVIEW *nmlv=lparam;
if(nmlv!=0){
sort_listview(hlistview,sort_dir,nmlv->iSubItem);
sort_dir=!sort_dir;
}
}
break;
case LVN_KEYDOWN:
if(nmhdr->hwndFrom==hlistview)
{
LV_KEYDOWN *key=lparam;
switch(key->wVKey){
case VK_DOWN:
case VK_RIGHT:
case VK_NEXT:
{
int count,row_sel;
count=ListView_GetItemCount(hlistview);
row_sel=ListView_GetSelectionMark(hlistview);
if(count>0 && row_sel==count-1)
SetFocus(GetDlgItem(hwnd,IDOK));
}
break;
case VK_DELETE:
clear_selected_items(hlistview);
break;
case VK_F5:
if(task_insert_row(win,hlistview))
SetWindowText(GetDlgItem(hwnd,IDOK),"Busy");
break;
case 'A':
if(GetKeyState(VK_CONTROL)&0x8000){
int i,count;
count=ListView_GetItemCount(hlistview);
for(i=0;i<count;i++){
ListView_SetItemState(hlistview,i,LVIS_SELECTED,LVIS_SELECTED);
}
break;
//.........这里部分代码省略.........
示例10: WindowProc
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
GL_Window* window = (GL_Window*)(GetWindowLong(hWnd, GWL_USERDATA));
switch (uMsg) // 取得Window的消息值
{
case WM_SYSCOMMAND: // 截取系统命令
{
switch (wParam) // 监听系统调用
{
case SC_SCREENSAVE: // 要运行屏保(Screensaver)?
case SC_MONITORPOWER: // 显示器进入节电模式(Powersave)?
return 0; // 提前返回0,防止系统调用执行
}
break; // 退出
}
case WM_CREATE: // 创建Window
{
CREATESTRUCT* creation = (CREATESTRUCT*)(lParam); // 保存窗口结构指针
window = (GL_Window*)(creation->lpCreateParams);
SetWindowLong(hWnd, GWL_USERDATA, (LONG)(window)); // 改变窗口属性
return 0; // 返回
}
case WM_CLOSE: // 关闭窗口
{
PostMessage(window->hWnd, WM_QUIT, 0, 0); // 结束程序
g_isProgramLooping = FALSE;
return 0;
}
case WM_SIZE: // WM_SIZE消息处理
switch (wParam) // 判断消息句柄
{
case SIZE_MINIMIZED: // 窗口最小化?
window->isVisible = FALSE; // 设置isVisible 为 FALSE
return 0;
case SIZE_MAXIMIZED: // 窗口最大化?
window->isVisible = TRUE; // 设置isVisible 为 TRUE
ResizeWindowGL (LOWORD (lParam), HIWORD (lParam)); // 修改窗口大小为 Width=LoWord, Height=HiWord
return 0; // 返回
case SIZE_RESTORED: // 窗口还原?
window->isVisible = TRUE; // 设置isVisible 为 TRUE
ResizeWindowGL (LOWORD (lParam), HIWORD (lParam)); // 修改窗口大小为 Width=LoWord, Height=HiWord
return 0; // 返回
}
break; // 退出
case WM_KEYDOWN: // 更新键盘缓冲区
if ((wParam >= 0) && (wParam <= 255)) // 按键是否合法?
{
window->keys->keyDown[wParam] = TRUE; // 设相应键为 TRUE (被按下的键)
return 0; // 返回
}
break; // 退出
case WM_KEYUP: // 松开按键的时候更新键盘缓冲
if ((wParam >= 0) && (wParam <= 255)) // 按键是否合法?
{
window->keys->keyDown[wParam] = FALSE; // 设相应键为 FALSE (被释放的键)
return 0; // 返回
}
break; // 退出
case WM_TOGGLEFULLSCREEN: // 切换全屏/窗口模式
{
g_createFullScreen = !g_createFullScreen;
PostMessage(hWnd, WM_QUIT, 0, 0);
break; // 退出
}
default:
break;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam); // 将本程序不处理的消息传给 DefWindowProc
}
示例11: DlgMain
// The main window procedure used by the dialog window
BOOL CALLBACK DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static HWND hRunButtonWnd; // A handle to the 'Run' button
static HWND hExitButtonWnd; // A handle to the 'Exit' button
switch(uMsg) // Search through messages sent to this window procedure
{
case WM_INITDIALOG: // Creating of the dialog window
if(SetLayeredWindowAttributes != NULL) // Make sure that this function exits
{
if(destroyCaption == false) { // Make sure that the caption has not already been destroyed
DestroyCaption(hwndDlg, pDialogSkin->getBitmapWidth(), pDialogSkin->getBitmapHeight()); // Destroy any window caption that may be set
destroyCaption = true; // Set a flag to ensure that this has been accomplished
}
SetWindowLong(hwndDlg, GWL_EXSTYLE, GetWindowLong(hwndDlg, GWL_EXSTYLE) | WS_EX_LAYERED); // Set the window style
SetLayeredWindowAttributes(hwndDlg, colorKey, 0, LWA_COLORKEY); // Set the transparency color key
}
hRunButtonWnd = ::GetDlgItem(hwndDlg,IDRUN); // Get the window handle for the 'Run' button
hExitButtonWnd = ::GetDlgItem(hwndDlg,IDEXIT); // Get the window handle for the 'Exit' button
return TRUE;
// draw our bitmap
case WM_PAINT: // Draw the dialog window
{
BITMAP bm; // Create a bitmap structure
PAINTSTRUCT ps; // Create a paint structure
HDC hdc = BeginPaint(hwndDlg, &ps); // Create a device context used for the dialog window
HDC dcSkin = CreateCompatibleDC(hdc); // Create a compatible memory device context to copy the color information from the bitmap to
GetObject(pDialogSkin->getBitmapHandle(), sizeof(bm), &bm); // Fill bitmap structure with information about the background image bitmap
SelectObject(dcSkin, pDialogSkin->getBitmapHandle()); // Select this bitmap into the memory device context
BitBlt(hdc, 0,0,pDialogSkin->getBitmapWidth(),pDialogSkin->getBitmapHeight(), dcSkin, 0, 0, SRCCOPY); // Performs bit-block transfer of bitmap pixels to the memory device context
DeleteDC(dcSkin); // Release the memory device context
EndPaint(hwndDlg, &ps); // End painting of dialog window
}
return true;
case WM_CLOSE: // Exit application
{
EndDialog(hwndDlg, 0); // Close down the dialog window
}
return TRUE;
case WM_COMMAND: // Button has been clicked
{
switch (LOWORD (wParam))
{
case IDRUN: // 'Run' button was clicked
EndDialog (hwndDlg, 0) ; // Close the dialog window (or anything else you want to happen)
return TRUE ;
case IDEXIT : // 'Exit' button was clicked
EndDialog (hwndDlg, 0) ; // Close the dialog window because the user is exiting the application
return TRUE ;
}
}
return TRUE;
case WM_MOUSEMOVE: // Mouse has been moved while over the dialog window area
{
if(pRunButton->isMouseOver()){ // Check to see if the mouse was previously over the 'Run' button
pRunButton->mouseIsOut(); // Set a flag to signify that the mouse is not hovering over the 'Run' button any more
if(pRunButton->isMouseLeftButtonDown()){// Check to see if the mouse button was previously flagged as down over the 'Run' button
pRunButton->mouseLeftUp(); // Set a flag to signify that the 'Run' button does not have the left mouse button clicked over it any more
}
InvalidateRgn(hRunButtonWnd, NULL, FALSE); // Redraw the 'Run' button with the default state
}
if(pExitButton->isMouseOver()){ // Check to see if the mouse was previously over the 'Exit' button
pExitButton->mouseIsOut(); // Set a flag to signify that the mouse is not hovering over the 'Exit' button any more
if(pExitButton->isMouseLeftButtonDown()){// Check to see if the mouse button was previously flagged as down over the 'Exit' button
pExitButton->mouseLeftUp(); // Set a flag to signify that the 'Exit' button does not have the left mouse button clicked over it any more
}
InvalidateRgn(hExitButtonWnd, NULL, FALSE); // Redraw the 'Exit' button with the default state
}
}
break;
// Moves the window when the user clicks anywhere not covered by a control. HTCAPTION specifies
// that all button clicks originate in the title bar area - even when the window has no title bar.
case WM_LBUTTONDOWN:
{
PostMessage(hwndDlg, WM_NCLBUTTONDOWN, HTCAPTION,0);
}
return TRUE;
case WM_LBUTTONUP: // The left mouse button was released
{
if(pRunButton->isMouseLeftButtonDown()){ // Check to see if the mouse button was previously flagged as down over the 'Run' button
pRunButton->mouseLeftUp(); // Set a flag to signify that the 'Run' button does not have the left mouse button clicked over it any more
InvalidateRgn(hRunButtonWnd, NULL, FALSE); // Redraw the 'Run' button in its default state
}
if(pExitButton->isMouseLeftButtonDown()){ // Check to see if the mouse button was previously flagged as down over the 'Exit' button
pExitButton->mouseLeftUp(); // Set a flag to signify that the 'Exit' button does not have the left mouse button clicked over it any more
InvalidateRgn(hExitButtonWnd, NULL, FALSE); // Redraw the 'Exit' button in its default state
}
}
//.........这里部分代码省略.........
示例12: BaseBar_WindowProc
//.........这里部分代码省略.........
{
REBARINFO rbi;
HIMAGELIST hilOld = BandCtrl_GetImageList(hwnd);
rbi.cbSize = sizeof(REBARINFO);
rbi.fMask = RBIM_IMAGELIST;
rbi.himl = (HIMAGELIST)lParam;
if (!SendMessage(lpbi->hwndRebar, RB_SETBARINFO, 0, (LPARAM) &rbi))
return ((LRESULT)NULL);
return ((LRESULT)hilOld);
}
case BCM_GETIMAGELIST:
{
REBARINFO rbi;
rbi.cbSize = sizeof(REBARINFO);
rbi.fMask = RBIM_IMAGELIST;
rbi.himl = 0;
if (!SendMessage(lpbi->hwndRebar, RB_GETBARINFO, 0, (LPARAM) &rbi))
return ((LRESULT)NULL);
return ((LRESULT)rbi.himl);
}
case BCM_SETTITLEIMAGE:
{
REBARBANDINFO rbBand;
ZeroMemory(&rbBand, sizeof(REBARBANDINFO));
rbBand.cbSize = sizeof(REBARBANDINFO);
rbBand.fMask = RBBIM_IMAGE;
rbBand.iImage = wParam;
return (SendMessage(lpbi->hwndRebar, RB_SETBANDINFO, 0, (LPARAM)&rbBand));
}
case BCM_GETTITLEIMAGE:
{
REBARBANDINFO rbBand;
ZeroMemory(&rbBand, sizeof(REBARBANDINFO));
rbBand.cbSize = sizeof(REBARBANDINFO);
rbBand.fMask = RBBIM_IMAGE;
rbBand.iImage = -1;
SendMessage(lpbi->hwndRebar, RB_GETBANDINFO, 0, (LPARAM)&rbBand);
return (rbBand.iImage);
}
case BCM_GETALIGNMENT:
return ((LRESULT)lpbi->dwAlign);
case BCM_SETALIGNMENT:
{
NMHDR nmhdr;
DWORD dwStyle;
if (lpbi->dwAlign == wParam)
return (wParam);
lpbi->dwAlign = wParam;
dwStyle = GetWindowLong(lpbi->hwndRebar, GWL_STYLE);
dwStyle &= ~(CCS_BOTTOM | CCS_TOP | CCS_LEFT | CCS_RIGHT);
dwStyle |= lpbi->dwAlign;
SetWindowLong(lpbi->hwndRebar, GWL_STYLE, dwStyle);
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
nmhdr.code = RBN_HEIGHTCHANGE;
nmhdr.hwndFrom = hwnd;
nmhdr.idFrom = GetDlgCtrlID(hwnd);
SendMessage(GetParent(hwnd), WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr);
return (lpbi->dwAlign);
}
case BCM_SETDATA:
{
LPARAM lParamOld = lpbi->lParam;
lpbi->lParam = lParam;
return (lParamOld);
}
case BCM_GETDATA:
return (lpbi->lParam);
case BCM_SETALLOWABLEALIGNS:
{
DWORD dwOldAllowableAligns = lpbi->dwAllowableAligns;
lpbi->dwAllowableAligns = lParam;
return (dwOldAllowableAligns);
}
case BCM_GETALLOWABLEALIGNS:
return (lpbi->dwAllowableAligns);
}
return (DefWindowProc(hwnd, uMessage, wParam, lParam));
}
示例13: Sys_CreateConsole
//.........这里部分代码省略.........
hDC = GetDC( GetDesktopWindow() );
swidth = GetDeviceCaps( hDC, HORZRES );
sheight = GetDeviceCaps( hDC, VERTRES );
ReleaseDC( GetDesktopWindow(), hDC );
s_wcd.windowWidth = rect.right - rect.left + 1;
s_wcd.windowHeight = rect.bottom - rect.top + 1;
//s_wcd.hbmLogo = LoadBitmap( win32.hInstance, MAKEINTRESOURCE( IDB_BITMAP_LOGO) );
s_wcd.hWnd = CreateWindowExA( 0,
DEDCLASS,
"DOOM3-FH",
DEDSTYLE,
( swidth - 600 ) / 2, ( sheight - 450 ) / 2 , rect.right - rect.left + 1, rect.bottom - rect.top + 1,
NULL,
NULL,
win32.hInstance,
NULL );
if ( s_wcd.hWnd == NULL ) {
return;
}
//
// create fonts
//
hDC = GetDC( s_wcd.hWnd );
nHeight = -MulDiv( 8, GetDeviceCaps( hDC, LOGPIXELSY ), 72 );
s_wcd.hfBufferFont = CreateFontA( nHeight, 0, 0, 0, FW_LIGHT, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_MODERN | FIXED_PITCH, "Courier New" );
ReleaseDC( s_wcd.hWnd, hDC );
//
// create the input line
//
s_wcd.hwndInputLine = CreateWindowA( "edit", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER |
ES_LEFT | ES_AUTOHSCROLL,
6, 400, 528, 20,
s_wcd.hWnd,
( HMENU ) INPUT_ID, // child window ID
win32.hInstance, NULL );
//
// create the buttons
//
s_wcd.hwndButtonCopy = CreateWindowA( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
5, 425, 72, 24,
s_wcd.hWnd,
( HMENU ) COPY_ID, // child window ID
win32.hInstance, NULL );
SendMessage( s_wcd.hwndButtonCopy, WM_SETTEXT, 0, ( LPARAM ) "copy" );
s_wcd.hwndButtonClear = CreateWindowA( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
82, 425, 72, 24,
s_wcd.hWnd,
( HMENU ) CLEAR_ID, // child window ID
win32.hInstance, NULL );
SendMessage( s_wcd.hwndButtonClear, WM_SETTEXT, 0, ( LPARAM ) "clear" );
s_wcd.hwndButtonQuit = CreateWindowA( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
462, 425, 72, 24,
s_wcd.hWnd,
( HMENU ) QUIT_ID, // child window ID
win32.hInstance, NULL );
SendMessage( s_wcd.hwndButtonQuit, WM_SETTEXT, 0, ( LPARAM ) "quit" );
//
// create the scrollbuffer
//
s_wcd.hwndBuffer = CreateWindowA( "edit", NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER |
ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY,
6, 40, 526, 354,
s_wcd.hWnd,
( HMENU ) EDIT_ID, // child window ID
win32.hInstance, NULL );
SendMessage( s_wcd.hwndBuffer, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 );
s_wcd.SysInputLineWndProc = ( WNDPROC ) SetWindowLong( s_wcd.hwndInputLine, GWL_WNDPROC, ( long ) InputLineWndProc );
SendMessage( s_wcd.hwndInputLine, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 );
// don't show it now that we have a splash screen up
if ( win32.win_viewlog.GetBool() ) {
ShowWindow( s_wcd.hWnd, SW_SHOWDEFAULT);
UpdateWindow( s_wcd.hWnd );
SetForegroundWindow( s_wcd.hWnd );
SetFocus( s_wcd.hwndInputLine );
}
s_wcd.consoleField.Clear();
for ( i = 0 ; i < COMMAND_HISTORY ; i++ ) {
s_wcd.historyEditLines[i].Clear();
}
}
示例14: TSButtonWndProc
static LRESULT CALLBACK TSButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
MButtonCtrl *bct = (MButtonCtrl *) GetWindowLong(hwndDlg, 0);
switch (msg) {
case WM_NCCREATE:
{
SetWindowLong(hwndDlg, GWL_STYLE, GetWindowLong(hwndDlg, GWL_STYLE) | BS_OWNERDRAW);
bct = malloc(sizeof(MButtonCtrl));
if (bct == NULL)
return FALSE;
bct->hwnd = hwndDlg;
bct->stateId = PBS_NORMAL;
bct->focus = 0;
bct->hFont = GetStockObject(DEFAULT_GUI_FONT);
bct->arrow = NULL;
bct->defbutton = 0;
bct->hIcon = bct->hIconPrivate = 0;
bct->iIcon = 0;
bct->hIml = 0;
bct->hBitmap = NULL;
bct->pushBtn = 0;
bct->pbState = 0;
bct->hThemeButton = NULL;
bct->hThemeToolbar = NULL;
bct->cHot = 0;
bct->flatBtn = 0;
bct->bThemed = FALSE;
bct->bSkinned = bct->bSendOnDown = 0;
bct->buttonItem = NULL;
LoadTheme(bct);
SetWindowLong(hwndDlg, 0, (LONG) bct);
if (((CREATESTRUCTA *) lParam)->lpszName)
SetWindowText(hwndDlg, ((CREATESTRUCT *) lParam)->lpszName);
return TRUE;
}
case WM_DESTROY:
{
if (bct) {
if (hwndToolTips) {
TOOLINFO ti;
ZeroMemory(&ti, sizeof(ti));
ti.cbSize = sizeof(ti);
ti.uFlags = TTF_IDISHWND;
ti.hwnd = bct->hwnd;
ti.uId = (UINT) bct->hwnd;
if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM) &ti)) {
SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM) &ti);
}
if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM) &ti) == 0) {
DestroyWindow(hwndToolTips);
hwndToolTips = NULL;
}
}
if (bct->hIconPrivate)
DestroyIcon(bct->hIconPrivate);
DestroyTheme(bct);
free(bct);
}
SetWindowLong(hwndDlg, 0, (LONG) NULL);
break; // DONT! fall thru
}
case WM_SETTEXT:
{
bct->cHot = 0;
if ((char*) lParam) {
char *tmp = (char *) lParam;
while (*tmp) {
if (*tmp == '&' && *(tmp + 1)) {
bct->cHot = tolower(*(tmp + 1));
break;
}
tmp++;
}
InvalidateRect(bct->hwnd, NULL, TRUE);
lstrcpyn(bct->szText, (TCHAR *)lParam, 127);
bct->szText[127] = 0;
}
break;
}
case WM_SYSKEYUP:
if (bct->stateId != PBS_DISABLED && bct->cHot && bct->cHot == tolower((int) wParam)) {
if (bct->pushBtn) {
if (bct->pbState)
bct->pbState = 0;
else
bct->pbState = 1;
InvalidateRect(bct->hwnd, NULL, TRUE);
}
if(!bct->bSendOnDown)
SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
return 0;
}
break;
case WM_THEMECHANGED:
{
// themed changed, reload theme object
if (bct->bThemed)
LoadTheme(bct);
InvalidateRect(bct->hwnd, NULL, TRUE); // repaint it
//.........这里部分代码省略.........
示例15: wxCHECK_MSG
// same as AddPage() but does it at given position
bool wxNotebook::InsertPage(size_t nPage,
wxNotebookPage *pPage,
const wxString& strText,
bool bSelect,
int imageId)
{
wxCHECK_MSG( pPage != NULL, false, wxT("NULL page in wxNotebook::InsertPage") );
wxCHECK_MSG( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), false,
wxT("invalid index in wxNotebook::InsertPage") );
wxASSERT_MSG( pPage->GetParent() == this,
wxT("notebook pages must have notebook as parent") );
// add a new tab to the control
// ----------------------------
// init all fields to 0
TC_ITEM tcItem;
wxZeroMemory(tcItem);
// set the image, if any
if ( imageId != -1 )
{
tcItem.mask |= TCIF_IMAGE;
tcItem.iImage = imageId;
}
// and the text
if ( !strText.empty() )
{
tcItem.mask |= TCIF_TEXT;
tcItem.pszText = wxMSW_CONV_LPTSTR(strText);
}
// hide the page: unless it is selected, it shouldn't be shown (and if it
// is selected it will be shown later)
HWND hwnd = GetWinHwnd(pPage);
SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_VISIBLE);
// this updates internal flag too -- otherwise it would get out of sync
// with the real state
pPage->Show(false);
// fit the notebook page to the tab control's display area: this should be
// done before adding it to the notebook or TabCtrl_InsertItem() will
// change the notebooks size itself!
AdjustPageSize(pPage);
// finally do insert it
if ( TabCtrl_InsertItem(GetHwnd(), nPage, &tcItem) == -1 )
{
wxLogError(wxT("Can't create the notebook page '%s'."), strText.c_str());
return false;
}
// need to update the bg brush when the first page is added
// so the first panel gets the correct themed background
if ( m_pages.empty() )
{
#if wxUSE_UXTHEME
UpdateBgBrush();
#endif // wxUSE_UXTHEME
}
// succeeded: save the pointer to the page
m_pages.Insert(pPage, nPage);
// we may need to adjust the size again if the notebook size changed:
// normally this only happens for the first page we add (the tabs which
// hadn't been there before are now shown) but for a multiline notebook it
// can happen for any page at all as a new row could have been started
if ( m_pages.GetCount() == 1 || HasFlag(wxNB_MULTILINE) )
{
AdjustPageSize(pPage);
// Additionally, force the layout of the notebook itself by posting a
// size event to it. If we don't do it, notebooks with pages on the
// left or the right side may fail to account for the fact that they
// are now big enough to fit all all of their pages on one row and
// still reserve space for the second row of tabs, see #1792.
const wxSize s = GetSize();
::PostMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(s.x, s.y));
}
// now deal with the selection
// ---------------------------
// if the inserted page is before the selected one, we must update the
// index of the selected page
if ( int(nPage) <= m_selection )
{
// one extra page added
m_selection++;
}
DoSetSelectionAfterInsertion(nPage, bSelect);
//.........这里部分代码省略.........