本文整理汇总了C++中CallWindowProc函数的典型用法代码示例。如果您正苦于以下问题:C++ CallWindowProc函数的具体用法?C++ CallWindowProc怎么用?C++ CallWindowProc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CallWindowProc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: device_list_wndproc
INT_PTR CALLBACK device_list_wndproc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
TCHAR tipText[80];
POINT pt;
static int oldX, oldY;
int newX, newY;
LVHITTESTINFO hitTestInfo;
LVITEM lvitem;
device_context_t* dev_context;
BOOL ignored;
switch(message)
{
case WM_MOUSELEAVE:
// The mouse pointer has left our window.
// Deactivate the tooltip.
SendMessage(g_hwndTrackingTT, TTM_TRACKACTIVATE, (WPARAM)FALSE, (LPARAM)&g_toolItem);
g_TrackingMouse = FALSE;
return FALSE;
case WM_MOUSEMOVE:
if (!g_TrackingMouse)
{
// The mouse has just entered the window.
// Request notification when the mouse leaves.
TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT) };
tme.hwndTrack = hDlg;
tme.dwFlags = TME_LEAVE;
TrackMouseEvent(&tme);
// Activate the tooltip.
SendMessage(g_hwndTrackingTT, TTM_TRACKACTIVATE,
(WPARAM)TRUE, (LPARAM)&g_toolItem);
g_TrackingMouse = TRUE;
}
newX = LOWORD(lParam);
newY = HIWORD(lParam);
// Make sure the mouse has actually moved. The presence of the tooltip
// causes Windows to send the message continuously.
if ((newX != oldX) || (newY != oldY))
{
oldX = newX;
oldY = newY;
memset(&hitTestInfo,0,sizeof(hitTestInfo));
hitTestInfo.pt.x = newX;
hitTestInfo.pt.y = newY;
if ((ListView_HitTest(hDlg, &hitTestInfo) == -1) || newX > ListView_GetColumnWidth(hDlg, 0))
{
safe_sprintf(tipText, sizeof(tipText) - 1, TEXT("%s"), TEXT(""));
SendMessage(g_hwndTrackingTT, TTM_TRACKACTIVATE,FALSE, (LPARAM)&g_toolItem);
}
else
{
SendMessage(g_hwndTrackingTT, TTM_SETDELAYTIME,TTDT_INITIAL, 1000);
memset(&lvitem, 0 , sizeof(lvitem));
lvitem.iItem = hitTestInfo.iItem;
lvitem.mask = LVIF_PARAM;
ignored = ListView_GetItem(hDlg,&lvitem);
dev_context = (device_context_t*)lvitem.lParam;
// Update the text.
safe_sprintf(tipText, sizeof(tipText)-1 , TEXT("%s"), wdi_get_vendor_name(dev_context->wdi->vid));
SendMessage(g_hwndTrackingTT, TTM_TRACKACTIVATE,TRUE, (LPARAM)&g_toolItem);
}
g_toolItem.lpszText = tipText;
SendMessage(g_hwndTrackingTT, TTM_SETTOOLINFO, 0, (LPARAM)&g_toolItem);
// Position the tooltip.
// The coordinates are adjusted so that the tooltip does not
// overlap the mouse pointer.
pt.x = newX;
pt.y = newY;
ClientToScreen(hDlg, &pt);
SendMessage(g_hwndTrackingTT, TTM_TRACKPOSITION,
0, (LPARAM)MAKELONG(pt.x + 10, pt.y - 20));
}
break;
}
return CallWindowProc(device_list_wndproc_orig, hDlg, message, wParam, lParam);
}
示例2: ConnListBoxProc
LRESULT CALLBACK ConnListBoxProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_LBUTTONDOWN:
{
int index = SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam);
if(index >= 0x10000)
{
SendMessage(hwnd, LB_SETCURSEL, (DWORD)-1, 0L);
}
}
break;
case WM_RBUTTONDOWN:
{
POINT pos;
MENUITEMINFO info;
HMENU hMenu;
DWORD dwID;
int index = SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam);
if(index < 0x10000)
{
SendMessage(hwnd, LB_SETCURSEL, (DWORD)index, 1L);
}
else
{
SendMessage(hwnd, LB_SETCURSEL, (DWORD)-1, 0L);
break;
}
hMenu = CreatePopupMenu();
memset(&info, 0, sizeof(MENUITEMINFO));
info.cbSize = sizeof(MENUITEMINFO);
info.fMask = MIIM_ID | MIIM_TYPE;
info.fType = MFT_STRING;
info.wID = 1001;
info.dwTypeData = "切断(&X)";
InsertMenuItem(hMenu, -1, true, &info);
GetCursorPos(&pos);
dwID = TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RETURNCMD, pos.x, pos.y, 0, hwnd, NULL);
DestroyMenu(hMenu);
switch(dwID)
{
case 1001:
SendMessage(guiWnd, WM_COMMAND, IDC_BUTTON6, NULL);
break;
}
}
break;
}
return CallWindowProc(wndOldConnListBox, hwnd, message, wParam, lParam);
}
示例3: SpringWndProc
static LRESULT CALLBACK SpringWndProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (mouse) {
switch (msg) {
case WM_XBUTTONDOWN:
{
if ((short)LOWORD(wParam) & MK_XBUTTON1)
mouse->MousePress((short)LOWORD(lParam), (short)HIWORD(lParam), 4);
if ((short)LOWORD(wParam) & MK_XBUTTON2)
mouse->MousePress((short)LOWORD(lParam), (short)HIWORD(lParam), 5);
} return 0;
case WM_XBUTTONUP:
{
if ((short)LOWORD(wParam) & MK_XBUTTON1)
mouse->MouseRelease((short)LOWORD(lParam), (short)HIWORD(lParam), 4);
if ((short)LOWORD(wParam) & MK_XBUTTON2)
mouse->MouseRelease((short)LOWORD(lParam), (short)HIWORD(lParam), 5);
} return 0;
}
}
switch (msg) {
case WM_MOUSEMOVE:
return wsdl::OnMouseMotion(wnd, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)wParam);
case WM_MOUSEWHEEL:
return wsdl::OnMouseWheel(wnd, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (int)(short)HIWORD(wParam), (UINT)(short)LOWORD(wParam));
//! can't use message crackers: they do not provide for passing uMsg
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
return wsdl::OnMouseButton(wnd, msg, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)wParam);
case WM_SETCURSOR:
{
if (inst->hCursor!=NULL) {
Uint16 hittest = LOWORD(lParam);
if ( hittest == HTCLIENT ) {
SetCursor(inst->hCursor);
return TRUE;
}
}
} break;
case WM_ACTIVATE:
{
wsdl::ResetMouseButtons();
// wsdl::OnActivate(wnd, LOWORD(wParam), NULL, HIWORD(lParam));
// FIXME: move to SpringApp somehow and use GLContext.h instead!
if (globalRendering->fullScreen) {
if (LOWORD(wParam) == WA_INACTIVE) {
FBO::GLContextLost();
} else if (LOWORD(wParam) == WA_ACTIVE) {
FBO::GLContextReinit();
}
}
} break;
}
return CallWindowProc((WNDPROC)inst->sdl_wndproc, wnd, msg, wParam, lParam);
}
示例4: WndProc
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
HWND hwndParent = hWndParent;
HWND hwndImage = hWndImage;
if (hwnd == hwndParent) {
if (message == WM_SIZE) {
ShowWindow(hwndImage, wParam == SIZE_MINIMIZED ? SW_HIDE : SW_SHOW);
}
if (message == WM_WINDOWPOSCHANGED) {
SetWindowPos(hwndImage, hwndParent, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
}
return CallWindowProc(
(long (__stdcall *)(HWND,unsigned int,unsigned int,long))oldProc,
hwnd,
message,
wParam,
lParam
);
}
switch (message) {
case WM_PAINT:
if (bgBitmap.bReady) {
ECS();
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
if (bgBitmap.iType == MIL_BITMAP) {
HDC cdc = CreateCompatibleDC(hdc);
SelectObject(cdc, bgBitmap.hBitmap);
for (unsigned int x = 0; x < uWndWidth; x += bgBitmap.rPos.right) {
for (unsigned int y = 0; y < uWndHeight; y += bgBitmap.rPos.bottom) {
BitBlt(hdc, x, y, bgBitmap.rPos.right, bgBitmap.rPos.bottom, cdc, 0, 0, SRCCOPY);
}
}
DeleteDC(cdc);
}
else {
int r = GetRValue(bgBitmap.cGradientFrom) << 10;
int g = GetGValue(bgBitmap.cGradientFrom) << 10;
int b = GetBValue(bgBitmap.cGradientFrom) << 10;
int dr = ((GetRValue(bgBitmap.cGradientTo) << 10) - r) / (int)uWndHeight * 4;
int dg = ((GetGValue(bgBitmap.cGradientTo) << 10) - g) / (int)uWndHeight * 4;
int db = ((GetBValue(bgBitmap.cGradientTo) << 10) - b) / (int)uWndHeight * 4;
RECT rect;
rect.left = 0;
rect.top = 0;
rect.right = uWndWidth;
rect.bottom = 4;
while (rect.top < (int)uWndHeight)
{
HBRUSH brush = CreateSolidBrush(RGB(r>>10,g>>10,b>>10));
FillRect(hdc, &rect, brush);
DeleteObject(brush);
rect.top+=4;
rect.bottom+=4;
r+=dr;
g+=dg;
b+=db;
}
}
myImageList *img = bgBitmap.next;
while (img) {
if (img->iType == MIL_TEXT) {
SetBkMode(hdc, TRANSPARENT);
SetTextColor(hdc, img->cTextColor);
SelectObject(hdc, img->hFont);
DrawText(hdc, img->szText, -1, &img->rPos, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_WORDBREAK);
}
else if (img->iType == MIL_BITMAP) {
HDC cdc = CreateCompatibleDC(hdc);
SelectObject(cdc, img->hBitmap);
BitBlt(hdc, img->rPos.left, img->rPos.top, img->rPos.right - img->rPos.left, img->rPos.bottom - img->rPos.top, cdc, 0, 0, SRCCOPY);
DeleteDC(cdc);
}
else {
COLORREF cColor;
HBITMAP bmAndBack, bmAndObject, bmAndMem, bmSave;
HBITMAP bmBackOld, bmObjectOld, bmMemOld, bmSaveOld;
HDC hdcMem, hdcBack, hdcObject, hdcTemp, hdcSave;
POINT ptSize;
HBITMAP hBitmap = img->hBitmap;
hdcTemp = CreateCompatibleDC(hdc);
SelectObject(hdcTemp, hBitmap); // Select the bitmap
ptSize.x = img->rPos.right - img->rPos.left;
ptSize.y = img->rPos.bottom - img->rPos.top;
DPtoLP(hdcTemp, &ptSize, 1); // Convert from device to logical points
// Create some DCs to hold temporary data.
hdcBack = CreateCompatibleDC(hdc);
hdcObject = CreateCompatibleDC(hdc);
hdcMem = CreateCompatibleDC(hdc);
hdcSave = CreateCompatibleDC(hdc);
// Create a bitmap for each DC. DCs are required for a number of
//.........这里部分代码省略.........
示例5: NewButtonWndProc
//
// Subclass procedure for the OVEN pushbutton window instance.
// The purpose of having this subclass is to do all "OVEN" related
// messages separately here. In particular, it processes these messages:
// - WM_MOUSEMOVE
// - WM_CHAR
// - WM_TIMER
//
LRESULT APIENTRY NewButtonWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
RECT rect;
POINT pt;
//HWND parent;
switch (uMsg) {
// The WM_MOUSEMOVE message is posted whenever the mouse is moved.
// If no window is captured, this message is posted to the window where cursor is;
// Otherwise, it is posted to the capture window.
//
// The default wndproc must NOT check for MouseMovement.
// First entry into this code will be when cursor is over button.
//
// Use PtInRect() to check if the cursor is placed over the button window area.
// If so, turn OVEN on.
// Use PtInRect() to check if the cursor is placed outside the button window area.
// If so, turn OVEN off.
//
// When the mouse is over OVEN button, capture window with SetCapture(),
// so subsequent mousemove to outside of OVEN button will still be processed here.
//
case WM_MOUSEMOVE:
GetClientRect(hwnd, &rect); // get rect of button window
pt.x = LOWORD(lParam); // is this client co-ordinate the button, or parent window?
pt.y = HIWORD(lParam);
// fill start here
if(PtInRect(&rect, pt)) {
SetToasted(hwnd, 1);
SetCapture(hwnd);
}else
{
SetToasted(hwnd, 0);
ReleaseCapture();
}
// fill end here
return 0;
// The WM_CHAR message is generated by the OS when a keyboard key is pressed,
// and the system calls TranslateMessage(). By default this message is
// sent to the window where keyboard was pressed, or the to keyboard
// focus window (which we have set to be the OVEN button using SetFocus()).
// That's why we are processing this message here, in the OVEN button subclass proc.
case WM_CHAR:
// fill start here
switch(wParam) {
case 'b':
SetToasted(hwnd, 1);
SetTimer(hwnd, 1, 5000, NULL);
Sleep(5000);
}
// fill end here
return 0;
case WM_TIMER: // this message is generated when timer timesout.
SetToasted(hwnd, 0); // set OVEN OFF
return 0;
}
// return to original wndproc and process all other messages there.
return CallWindowProc((WNDPROC)GetClassLong(GetParent(hwnd),0), hwnd, uMsg, wParam, lParam);
}
示例6: switch
LRESULT CALLBACK CCoolMenu::MenuProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
WNDPROC pWndProc = (WNDPROC)::GetProp( hWnd, wpnOldProc );
switch ( uMsg )
{
case WM_NCCALCSIZE:
{
NCCALCSIZE_PARAMS* pCalc = (NCCALCSIZE_PARAMS*)lParam;
pCalc->rgrc[0].left ++;
pCalc->rgrc[0].top ++;
pCalc->rgrc[0].right --;
pCalc->rgrc[0].bottom --;
}
return 0;
case WM_WINDOWPOSCHANGING:
if ( WINDOWPOS* pWndPos = (WINDOWPOS*)lParam )
{
DWORD nStyle = GetWindowLong( hWnd, GWL_STYLE );
DWORD nExStyle = GetWindowLong( hWnd, GWL_EXSTYLE );
CRect rc( 0, 0, 32, 32 );
AdjustWindowRectEx( &rc, nStyle, FALSE, nExStyle );
pWndPos->cx -= ( rc.Width() - 34 );
pWndPos->cy -= ( rc.Height() - 34 ) - 1;
if ( pWndPos->x != m_nEdgeLeft || pWndPos->y != m_nEdgeTop )
pWndPos->x ++;
}
break;
case WM_PRINT:
if ( ( lParam & PRF_CHECKVISIBLE ) && ! IsWindowVisible( hWnd ) ) return 0;
if ( lParam & PRF_NONCLIENT )
{
CWnd* pWnd = CWnd::FromHandle( hWnd );
CDC* pDC = CDC::FromHandle( (HDC)wParam );
CRect rc;
pWnd->GetWindowRect( &rc );
BOOL bEdge = ( rc.left == m_nEdgeLeft && rc.top == m_nEdgeTop );
rc.OffsetRect( -rc.left, -rc.top );
pDC->Draw3dRect( &rc, CoolInterface.m_crDisabled, CoolInterface.m_crDisabled );
if ( bEdge ) pDC->FillSolidRect( rc.left + 1, rc.top, min( rc.Width(), m_nEdgeSize ) - 2, 1, CoolInterface.m_crBackNormal );
}
if ( lParam & PRF_CLIENT )
{
CWnd* pWnd = CWnd::FromHandle( hWnd );
CDC* pDC = CDC::FromHandle( (HDC)wParam );
CBitmap bmBuf, *pbmOld;
CDC dcBuf;
CRect rc;
pWnd->GetClientRect( &rc );
dcBuf.CreateCompatibleDC( pDC );
bmBuf.CreateCompatibleBitmap( pDC, rc.Width(), rc.Height() );
pbmOld = (CBitmap*)dcBuf.SelectObject( &bmBuf );
m_bPrinted = TRUE;
dcBuf.FillSolidRect( &rc, GetSysColor( COLOR_MENU ) );
SendMessage( hWnd, WM_PRINTCLIENT, (WPARAM)dcBuf.GetSafeHdc(), 0 );
pDC->BitBlt( 1, 1, rc.Width(), rc.Height(), &dcBuf, 0, 0, SRCCOPY );
dcBuf.SelectObject( pbmOld );
}
return 0;
case WM_NCPAINT:
{
CWnd* pWnd = CWnd::FromHandle( hWnd );
CWindowDC dc( pWnd );
CRect rc;
pWnd->GetWindowRect( &rc );
BOOL bEdge = ( rc.left == m_nEdgeLeft && rc.top == m_nEdgeTop );
rc.OffsetRect( -rc.left, -rc.top );
dc.Draw3dRect( &rc, CoolInterface.m_crDisabled, CoolInterface.m_crDisabled );
if ( bEdge ) dc.FillSolidRect( rc.left + 1, rc.top, min( rc.Width(), m_nEdgeSize ) - 2, 1, CoolInterface.m_crBackNormal );
}
return 0;
case WM_PAINT:
m_bPrinted = FALSE;
break;
case WM_NCDESTROY:
::RemoveProp( hWnd, wpnOldProc );
break;
}
return CallWindowProc( pWndProc, hWnd, uMsg, wParam, lParam );
}
示例7: StandButtonProc
//.........这里部分代码省略.........
RedrawWindow(gameEngine->getHWnd(), NULL, NULL,
RDW_INVALIDATE | RDW_UPDATENOW);
Sleep(500);
//
// See if we need additional cards.
//
while (true) {
std::vector<int>* vals = dealerHand->GetValues();
bool done = false;
for (int i = 0; i < vals->size(); i++) {
// Dealer must stop taking cards
// if he has a value of 17 or higher.
if (vals->at(i) >= 17) {
done = true;
break;
}
}
if (done) {
break;
}
PlaySound(L"sound-flipcard.wav", NULL, SND_FILENAME | SND_ASYNC);
dealerHand->dealCard(false);
RedrawWindow(gameEngine->getHWnd(), NULL, NULL,
RDW_INVALIDATE | RDW_UPDATENOW);
Sleep(500);
}
//
// Determine winner. Update balance amounts.
//
// table->setState(TABLE_STATE_READY);
std::vector<int>* dealerValues = dealerHand->GetValues();
std::vector<int>* playerValues = playerHand->GetValues();
int dealerFinal = 0;
int playerFinal = 0;
for (int i = 0; i < dealerValues->size(); i++) {
if (dealerValues->at(i) > dealerFinal &&
dealerValues->at(i) < 22) {
dealerFinal = dealerValues->at(i);
}
}
for (int i = 0; i < playerValues->size(); i++) {
if (playerValues->at(i) > playerFinal &&
playerValues->at(i) < 22) {
playerFinal = playerValues->at(i);
}
}
table->setState(TABLE_STATE_FINISHED);
// If values are same, this is a push.
if (dealerFinal == playerFinal) {
updateTextarea(hStaticTableMiddleMessage, "Push");
// Return player's bet money.
int bet = playerHand->getBetAmount();
user->setBalance(user->getBalance() + bet);
} else if (dealerFinal < playerFinal) {
// Player wins, return bet and winning.
updateTextarea(hStaticTableMiddleMessage, "Player Wins!");
int bet = playerHand->getBetAmount();
user->setBalance(user->getBalance() + (bet*2) );
}
else if (dealerFinal > playerFinal) {
// No need to update cash. Has already been deducted
// at time of bet. Update the middle message area.
updateTextarea(hStaticTableMiddleMessage, "Dealer Wins.");
}
RedrawWindow(gameEngine->getHWnd(), NULL, NULL,
RDW_INVALIDATE | RDW_UPDATENOW);
}
return CallWindowProc(oldStandButtonProc, hwnd, msg, wp, lp);
}
示例8: PhListTick
static VOID PhListTick(
__in PPH_EXTLV_CONTEXT Context
)
{
HWND hwnd = Context->Handle;
ULONG tickCount;
BOOLEAN redrawDisabled = FALSE;
PPH_LIST itemsToRemove = NULL;
PH_HASHTABLE_ENUM_CONTEXT enumContext;
PPH_TICK_ENTRY entry;
if (!Context->TickHashtable)
return;
tickCount = GetTickCount();
// First pass
PhBeginEnumHashtable(Context->TickHashtable, &enumContext);
while (entry = PhNextEnumHashtable(&enumContext))
{
LVITEM item;
PH_ITEM_STATE itemState;
if (PhRoundNumber(tickCount - entry->TickCount, PH_DURATION_MULT) < Context->HighlightingDuration)
continue;
item.mask = LVIF_STATE;
item.iItem = ListView_MapIDToIndex(hwnd, entry->Id);
item.iSubItem = 0;
item.stateMask = LVIS_STATEIMAGEMASK;
CallWindowProc(Context->OldWndProc, hwnd, LVM_GETITEM, 0, (LPARAM)&item);
itemState = PH_GET_ITEM_STATE(item.state);
if (itemState == NewItemState)
{
item.state = INDEXTOSTATEIMAGEMASK(NormalItemState);
CallWindowProc(Context->OldWndProc, hwnd, LVM_SETITEM, 0, (LPARAM)&item);
if (!itemsToRemove)
itemsToRemove = PhCreateList(2);
PhAddItemList(itemsToRemove, (PVOID)entry->Id);
entry->TickCount = tickCount;
}
}
// Second pass
// This pass is specifically for deleting items.
PhBeginEnumHashtable(Context->TickHashtable, &enumContext);
while (entry = PhNextEnumHashtable(&enumContext))
{
LVITEM item;
PH_ITEM_STATE itemState;
if (itemsToRemove)
{
if (PhFindItemList(itemsToRemove, (PVOID)entry->Id) != -1)
continue;
}
if (PhRoundNumber(tickCount - entry->TickCount, PH_DURATION_MULT) < Context->HighlightingDuration)
continue;
item.mask = LVIF_STATE;
item.iItem = ListView_MapIDToIndex(hwnd, entry->Id);
item.iSubItem = 0;
item.stateMask = LVIS_STATEIMAGEMASK;
CallWindowProc(Context->OldWndProc, hwnd, LVM_GETITEM, 0, (LPARAM)&item);
itemState = PH_GET_ITEM_STATE(item.state);
if (itemState == RemovingItemState)
{
if (!redrawDisabled)
{
ExtendedListView_SetRedraw(hwnd, FALSE);
redrawDisabled = TRUE;
}
CallWindowProc(Context->OldWndProc, hwnd, LVM_DELETEITEM, item.iItem, 0);
if (!itemsToRemove)
itemsToRemove = PhCreateList(2);
PhAddItemList(itemsToRemove, (PVOID)entry->Id);
entry->TickCount = tickCount;
}
}
if (redrawDisabled)
{
ExtendedListView_SetRedraw(hwnd, TRUE);
}
if (itemsToRemove)
//.........这里部分代码省略.........
示例9: SubClassEdit
/*------------------------------------------------------------------------
Procedure: SubClassEdit ID:1
Purpose: Handles messages to the editbox
Input:
Output:
Errors:
--------------------------------------------------------------------------
Edit History:
14 Sept 2003 - Chris Watford [email protected]
- Setup handler for up and down arrows
15 Sept 2003 - Chris Watford [email protected]
- Setup framework for history on up arrow
- Saves lines you move off of in the edit buffer
16 Sept 2003 - Chris Watford [email protected]
- Proper handling of newline message finished
- Fixed ENTER on middle of interior line, moves cursor to the end
and sends the line
- Setup the copying and destroying of the old buffer
- Included buffer rewrite
17 Sept 2003 - Chris Watford [email protected]
- Added C-p/C-n support
- Changed UpArrow to C-UpArrow so as to not confuse users
18 Sept 2003 - Chris Watford [email protected]
- Added Left and Right arrow line saving
- Added backspace and delete line saving and removing
- Fixed history scrolling
21 Sept 2003 - Chris Watford [email protected]
- Fixed pasting errors associated with lines being out of bounds
for the buffer
- Added error handling, possibly able to handle it diff down the
line
- Removed C-Up/C-Dn for history scrolling, buggy at best on my
machine
------------------------------------------------------------------------*/
static LRESULT CALLBACK SubClassEdit(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2)
{
LRESULT r;
int postit=0,nl;
if (msg == WM_CHAR && mp1 == '\r') {
if (!busy) {
r = GetCurLineIndex(hwnd);
nl = GetNumberOfLines(hwnd);
// if we're not the last line
if (r != nl-1)
{
// update or add us, we might not have any lines in the edit buffer
editbuffer_updateoraddline(CurrentEditBuffer, r-LastPromptPosition.line, GetLastLine(hwnd));
// scroll to the end, add CrLf then post the newline message
GotoEOF();
AddStringToControl("\r\n");
PostMessage(GetParent(hwnd),WM_NEWLINE,0,0);
return 0;
}
CallWindowProc(lpEProc,hwnd,WM_KEYDOWN,VK_END,1);
CallWindowProc(lpEProc,hwnd,WM_KEYUP,VK_END,1);
postit = 1;
}
}
else if (msg == WM_CHAR && mp1 == (char)0x08) {
int lineindex = SendMessage(hwnd, EM_LINEINDEX, LastPromptPosition.line, 0) + 2;
int curline = SendMessage(hwnd,EM_LINEFROMCHAR,(WPARAM)-1,0);
int nextline = 0;
int curpoint = 0;
SendMessage(hwnd, EM_GETSEL, (WPARAM)&curpoint, (LPARAM)NULL);
nextline = SendMessage(hwnd,EM_LINEFROMCHAR,(WPARAM)(curpoint - 1),0);
if(curpoint <= lineindex)
{
return 0;
} else if(nextline != curline) {
// delete the line we're on
// grab the index
curline -= LastPromptPosition.line;
// kill it
editbuffer_removeline(CurrentEditBuffer, curline);
}
}
else if (msg == WM_KEYDOWN && mp1 == VK_F1) {
DoHelp(hwnd);
}
else if ((msg == WM_KEYDOWN || msg == WM_KEYUP) && mp1 == VK_UP) {
int curline = GetCurLineIndex(hwnd);
/*if((msg == WM_KEYDOWN) && (GetKeyState(VK_CONTROL) && 0x8000))
{ // go forward once in history
NextHistoryEntry();
return 0;
} else */
if((curline > LastPromptPosition.line) && (curline <= (LastPromptPosition.line + CurrentEditBuffer->LineCount)))
{
// update current line
//.........这里部分代码省略.........
示例10: DealButtonProc
//.........这里部分代码省略.........
if (msg == WM_LBUTTONDOWN) {
TCHAR buff[64];
GetWindowText(hTextboxBetAmount, buff, 20);
int bet = _ttoi(buff);
/*
for (int i = 0; buff[i] != NULL; i++) {
if (! std::isdigit(buff[i]) ) {
MessageBox(
GameEngine::getInstance()->getHWnd(),
L"Invalid bet amount.",
L"Error",
NULL);
return 0;
}
}
*/
// int bet = atoi(buff);
Table* table = GameEngine::getInstance()->getTable();
User* user = GameEngine::getInstance()->getUser();
// Can player bet this much?
if (bet > user->getBalance()) {
MessageBox(
GameEngine::getInstance()->getHWnd(),
L"Insufficient funds available to place this bet.",
L"Error",
NULL);
return 0;
}
if (bet == 0) {
MessageBox(
GameEngine::getInstance()->getHWnd(),
L"Must bet more than $0.",
L"Error",
NULL);
return 0;
}
Hand* dealerHand = new Hand();
Hand* playerHand = new Hand();
playerHand->setBetAmount(bet);
user->setBalance(user->getBalance() - bet);
dealerHand->dealCard(true);
dealerHand->dealCard(false);
playerHand->dealCard(false);
playerHand->dealCard(false);
table->setDealerHand(dealerHand);
table->setPlayerHand(playerHand);
GameEngine::getInstance()->setState(GameEngine::STATE_PLAYING);
PlaySound(L"sound-chips.wav", NULL, SND_FILENAME | SND_ASYNC);
//
// Check if we have blackjack, if so player
// wins right away. Otherwise move to substate
// "playing"
//
if (playerHand->isBlackjack()) {
table->setState(TABLE_STATE_FINISHED);
updateTextarea(hStaticTableMiddleMessage, "Blackjack! Player Wins.");
// Play YAY sound
PlaySound(L"sound-yay.wav", NULL, SND_FILENAME | SND_ASYNC);
// Update user balance.
user->setBalance(user->getBalance() + (bet*2));
} else {
table->setState(TABLE_STATE_PLAYING);
}
//
// Force redraw of window, which should now render the new
// card data.
//
// https://msdn.microsoft.com/en-us/library/dd162911%28VS.85%29.aspx
// http://stackoverflow.com/questions/2325894/difference-between-invalidaterect-and-redrawwindow
//
RedrawWindow(GameEngine::getInstance()->getHWnd(), NULL, NULL,
RDW_INVALIDATE | RDW_UPDATENOW);
return 0;
}
return CallWindowProc(oldDealButtonProc, hwnd, msg, wp, lp);
}
示例11: InputLineWndProc
LONG WINAPI InputLineWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
int key, cursor;
switch( uMsg ) {
case WM_KILLFOCUS:
if( ( HWND ) wParam == s_wcd.hWnd || ( HWND ) wParam == s_wcd.hwndErrorBox ) {
SetFocus( hWnd );
return 0;
}
break;
case WM_KEYDOWN:
key = MapKey( lParam );
// command history
if( ( key == K_UPARROW ) || ( key == K_KP_UPARROW ) ) {
if( s_wcd.nextHistoryLine - s_wcd.historyLine < COMMAND_HISTORY && s_wcd.historyLine > 0 ) {
s_wcd.historyLine--;
}
s_wcd.consoleField = s_wcd.historyEditLines[ s_wcd.historyLine % COMMAND_HISTORY ];
SetWindowText( s_wcd.hwndInputLine, s_wcd.consoleField.GetBuffer() );
SendMessage( s_wcd.hwndInputLine, EM_SETSEL, s_wcd.consoleField.GetCursor(), s_wcd.consoleField.GetCursor() );
return 0;
}
if( ( key == K_DOWNARROW ) || ( key == K_KP_DOWNARROW ) ) {
if( s_wcd.historyLine == s_wcd.nextHistoryLine ) {
return 0;
}
s_wcd.historyLine++;
s_wcd.consoleField = s_wcd.historyEditLines[ s_wcd.historyLine % COMMAND_HISTORY ];
SetWindowText( s_wcd.hwndInputLine, s_wcd.consoleField.GetBuffer() );
SendMessage( s_wcd.hwndInputLine, EM_SETSEL, s_wcd.consoleField.GetCursor(), s_wcd.consoleField.GetCursor() );
return 0;
}
break;
case WM_CHAR:
key = MapKey( lParam );
GetWindowText( s_wcd.hwndInputLine, s_wcd.consoleField.GetBuffer(), MAX_EDIT_LINE );
SendMessage( s_wcd.hwndInputLine, EM_GETSEL, ( WPARAM ) NULL, ( LPARAM ) &cursor );
s_wcd.consoleField.SetCursor( cursor );
// enter the line
if( key == K_ENTER || key == K_KP_ENTER ) {
strncat( s_wcd.consoleText, s_wcd.consoleField.GetBuffer(), sizeof( s_wcd.consoleText ) - strlen( s_wcd.consoleText ) - 5 );
strcat( s_wcd.consoleText, "\n" );
SetWindowText( s_wcd.hwndInputLine, "" );
Sys_Printf( "]%s\n", s_wcd.consoleField.GetBuffer() );
// copy line to history buffer
s_wcd.historyEditLines[s_wcd.nextHistoryLine % COMMAND_HISTORY] = s_wcd.consoleField;
s_wcd.nextHistoryLine++;
s_wcd.historyLine = s_wcd.nextHistoryLine;
s_wcd.consoleField.Clear();
return 0;
}
// command completion
if( key == K_TAB ) {
s_wcd.consoleField.AutoComplete();
SetWindowText( s_wcd.hwndInputLine, s_wcd.consoleField.GetBuffer() );
//s_wcd.consoleField.SetWidthInChars( strlen( s_wcd.consoleField.GetBuffer() ) );
SendMessage( s_wcd.hwndInputLine, EM_SETSEL, s_wcd.consoleField.GetCursor(), s_wcd.consoleField.GetCursor() );
return 0;
}
// clear autocompletion buffer on normal key input
if( ( key >= K_SPACE && key <= K_BACKSPACE ) ||
( key >= K_KP_SLASH && key <= K_KP_PLUS ) || ( key >= K_KP_STAR && key <= K_KP_EQUALS ) ) {
s_wcd.consoleField.ClearAutoComplete();
}
break;
}
return CallWindowProc( s_wcd.SysInputLineWndProc, hWnd, uMsg, wParam, lParam );
}
示例12: DIB_HandleMessage
//.........这里部分代码省略.........
return(0);
case WM_SYSKEYUP:
case WM_KEYUP: {
SDL_keysym keysym;
#ifdef SDL_VIDEO_DRIVER_GAPI
if(this->hidden->gapiInfo)
{
// Drop GAPI artifacts
if (wParam == 0x84 || wParam == 0x5B)
return 0;
wParam = rotateKey(wParam, this->hidden->gapiInfo->coordinateTransform);
}
#endif
switch (wParam) {
case VK_CONTROL:
if ( lParam&EXTENDED_KEYMASK )
wParam = VK_RCONTROL;
else
wParam = VK_LCONTROL;
break;
case VK_SHIFT:
/* EXTENDED trick doesn't work here */
{
Uint8 *state = SDL_GetKeyState(NULL);
if (state[SDLK_LSHIFT] == SDL_PRESSED && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
wParam = VK_LSHIFT;
} else if (state[SDLK_RSHIFT] == SDL_PRESSED && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
wParam = VK_RSHIFT;
} else {
/* Win9x */
int sc = HIWORD(lParam) & 0xFF;
if (sc == 0x2A)
wParam = VK_LSHIFT;
else
if (sc == 0x36)
wParam = VK_RSHIFT;
else
wParam = VK_LSHIFT;
}
}
break;
case VK_MENU:
if ( lParam&EXTENDED_KEYMASK )
wParam = VK_RMENU;
else
wParam = VK_LMENU;
break;
}
/* Windows only reports keyup for print screen */
if ( wParam == VK_SNAPSHOT && SDL_GetKeyState(NULL)[SDLK_PRINT] == SDL_RELEASED ) {
posted = SDL_PrivateKeyboard(SDL_PRESSED,
TranslateKey(wParam,HIWORD(lParam),&keysym,1));
}
posted = SDL_PrivateKeyboard(SDL_RELEASED,
TranslateKey(wParam,HIWORD(lParam),&keysym,0));
}
return(0);
#if defined(SC_SCREENSAVE) && defined(SC_MONITORPOWER)
case WM_SYSCOMMAND: {
const DWORD val = (DWORD) (wParam & 0xFFF0);
if ((val == SC_SCREENSAVE) || (val == SC_MONITORPOWER)) {
if (this->hidden->dibInfo && !allow_screensaver) {
/* Note that this doesn't stop anything on Vista
if the screensaver has a password. */
return(0);
}
}
}
/* Fall through to default processing */
#endif /* SC_SCREENSAVE && SC_MONITORPOWER */
default: {
/* Only post the event if we're watching for it */
if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
SDL_SysWMmsg wmmsg;
SDL_VERSION(&wmmsg.version);
wmmsg.hwnd = hwnd;
wmmsg.msg = msg;
wmmsg.wParam = wParam;
wmmsg.lParam = lParam;
posted = SDL_PrivateSysWMEvent(&wmmsg);
/* DJM: If the user isn't watching for private
messages in her SDL event loop, then pass it
along to any win32 specific window proc.
*/
} else if (userWindowProc) {
return CallWindowProc(userWindowProc, hwnd, msg, wParam, lParam);
}
}
break;
}
return(DefWindowProc(hwnd, msg, wParam, lParam));
}
示例13: switch
LRESULT CALLBACK CSearchBar::EditProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
CSearchBar* This = (CSearchBar*)::GetWindowLong(hwnd, GWL_USERDATA);
switch (msg)
{
case WM_KEYDOWN:
switch (wparam)
{
case VK_RETURN:
This->GetParent()->PostMessage(WM_COMMAND, ID_WEB_SEARCH, 0);
break;
case VK_ESCAPE:
return 0;
}
break;
case WM_CONTEXTMENU:
if (riched20)
{
HMENU menu = ::LoadMenu(AfxGetResourceHandle(), LPCTSTR(IDR_POPUP2));
HMENU popup = ::GetSubMenu(menu, 2);
TrackPopupMenu(popup, TPM_LEFTALIGN, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam), 0, hwnd, NULL);
DestroyMenu(menu);
return 0;
}
break;
case WM_COMMAND:
if (riched20)
{
switch (LOWORD(wparam))
{
case ID_EDIT_UNDO:
::SendMessage(hwnd, WM_UNDO, 0, 0);
return 0;
case ID_EDIT_CUT:
::SendMessage(hwnd, WM_CUT, 0, 0);
return 0;
case ID_EDIT_COPY:
::SendMessage(hwnd, WM_COPY, 0, 0);
return 0;
case ID_EDIT_PASTE:
::SendMessage(hwnd, WM_PASTE, 0, NULL);
return 0;
case ID_EDIT_DELETE:
::SendMessage(hwnd, WM_CLEAR, 0, 0);
return 0;
case ID_EDIT_SELALL:
{
CHARRANGE cr = {0, -1};
::SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&cr);
return 0;
}
}
}
break;
case WM_SETFOCUS:
CallWindowProc(This->old_search_bar_proc, hwnd, msg, wparam, lparam);
if (riched20)
{
CHARRANGE cr = {0, -1};
::SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&cr);
}
else
::SendMessage(hwnd, EM_SETSEL, 0, -1);
return 0;
case WM_GETDLGCODE:
return DLGC_WANTALLKEYS;
case WM_SETCURSOR:
if (riched20)
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_IBEAM));
break;
}
return CallWindowProc(This->old_search_bar_proc, hwnd, msg, wparam, lparam);
}
示例14: CardImageWndProc
LRESULT CALLBACK
CardImageWndProc(HWND hwnd,
UINT msg,
WPARAM wParam,
LPARAM lParam)
{
PCARDBACK pCardBack = (PCARDBACK)GetWindowLongPtr(hwnd,
GWL_USERDATA);
static WNDPROC hOldProc = NULL;
if (!hOldProc && pCardBack)
hOldProc = pCardBack->hOldProc;
switch (msg)
{
case WM_PAINT:
{
HDC hdc;
PAINTSTRUCT ps;
HPEN hPen, hOldPen;
HBRUSH hBrush, hOldBrush;
RECT rc;
hdc = BeginPaint(hwnd, &ps);
if (pCardBack->bSelected)
{
hPen = CreatePen(PS_SOLID, 2, RGB(0,0,0));
}
else
{
DWORD Face = GetSysColor(COLOR_3DFACE);
hPen = CreatePen(PS_SOLID, 2, Face);
}
GetClientRect(hwnd, &rc);
hBrush = (HBRUSH)GetStockObject(NULL_BRUSH);
hOldPen = (HPEN)SelectObject(hdc, hPen);
hOldBrush = (HBRUSH)SelectObject(hdc, hBrush);
Rectangle(hdc,
rc.left+1,
rc.top+1,
rc.right,
rc.bottom);
StretchBlt(hdc,
2,
2,
CARDBACK_OPTIONS_WIDTH,
CARDBACK_OPTIONS_HEIGHT,
__hdcCardBitmaps,
pCardBack->hdcNum * __cardwidth,
0,
__cardwidth,
__cardheight,
SRCCOPY);
SelectObject(hdc, hOldPen);
SelectObject(hdc, hOldBrush);
EndPaint(hwnd, &ps);
break;
}
case WM_LBUTTONDOWN:
pCardBack->bSelected = pCardBack->bSelected ? FALSE : TRUE;
break;
}
return CallWindowProc(hOldProc,
hwnd,
msg,
wParam,
lParam);
}
示例15: PhpExtendedListViewWndProc
LRESULT CALLBACK PhpExtendedListViewWndProc(
__in HWND hwnd,
__in UINT uMsg,
__in WPARAM wParam,
__in LPARAM lParam
)
{
PPH_EXTLV_CONTEXT context;
WNDPROC oldWndProc;
context = (PPH_EXTLV_CONTEXT)GetProp(hwnd, PhpMakeExtLvContextAtom());
oldWndProc = context->OldWndProc;
switch (uMsg)
{
case WM_DESTROY:
{
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)oldWndProc);
if (context->TickHashtable)
PhDereferenceObject(context->TickHashtable);
PhFree(context);
RemoveProp(hwnd, PhpMakeExtLvContextAtom());
}
break;
case WM_NOTIFY:
{
LPNMHDR header = (LPNMHDR)lParam;
switch (header->code)
{
case HDN_ITEMCLICK:
{
HWND headerHandle;
headerHandle = (HWND)CallWindowProc(context->OldWndProc, hwnd, LVM_GETHEADER, 0, 0);
if (header->hwndFrom == headerHandle)
{
LPNMHEADER header2 = (LPNMHEADER)header;
if (header2->iItem == context->SortColumn)
{
if (context->TriState)
{
if (context->SortOrder == AscendingSortOrder)
context->SortOrder = DescendingSortOrder;
else if (context->SortOrder == DescendingSortOrder)
context->SortOrder = NoSortOrder;
else
context->SortOrder = AscendingSortOrder;
}
else
{
if (context->SortOrder == AscendingSortOrder)
context->SortOrder = DescendingSortOrder;
else
context->SortOrder = AscendingSortOrder;
}
}
else
{
context->SortColumn = header2->iItem;
context->SortOrder = AscendingSortOrder;
}
PhSetHeaderSortIcon(headerHandle, context->SortColumn, context->SortOrder);
ExtendedListView_SortItems(hwnd);
}
}
break;
}
}
break;
case WM_REFLECT + WM_NOTIFY:
{
LPNMHDR header = (LPNMHDR)lParam;
switch (header->code)
{
case NM_CUSTOMDRAW:
{
if (header->hwndFrom == hwnd)
{
LPNMLVCUSTOMDRAW customDraw = (LPNMLVCUSTOMDRAW)header;
switch (customDraw->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
return CDRF_NOTIFYITEMDRAW;
case CDDS_ITEMPREPAINT:
{
LVITEM item;
PH_ITEM_STATE itemState;
BOOLEAN colorChanged = FALSE;
HFONT newFont = NULL;
item.mask = LVIF_STATE;
item.iItem = (INT)customDraw->nmcd.dwItemSpec;
//.........这里部分代码省略.........