From 01bc3d7c42a235ffa4117866bdf3977fe3a4aa0d Mon Sep 17 00:00:00 2001 From: VincentWei Date: Thu, 18 Jan 2018 19:01:29 +0800 Subject: [PATCH] tune code for 64 bits --- include/common.h | 2 ++ include/window.h | 6 +++--- src/control/button.c | 3 ++- src/gui/window.c | 2 +- src/kernel/desktop-comm.c | 1 - src/kernel/desktop-ths.c | 10 +++++----- src/kernel/message.c | 20 ++++++++++---------- src/misc/about.c | 6 ------ 8 files changed, 23 insertions(+), 27 deletions(-) diff --git a/include/common.h b/include/common.h index 658e7351..57667980 100644 --- a/include/common.h +++ b/include/common.h @@ -1885,8 +1885,10 @@ int init_minigui_printf (int (*output_char) (int ch), #if defined(__GNUC__) #ifdef _DEBUG # define _MG_PRINTF(fmt...) fprintf (stderr, fmt) +# define _DBG_PRINTF(fmt...) fprintf (stdout, fmt) #else # define _MG_PRINTF(fmt...) +# define _DBG_PRINTF(fmt...) #endif #else /* __GNUC__ */ #include diff --git a/include/window.h b/include/window.h index bc3f6a71..760e42b7 100644 --- a/include/window.h +++ b/include/window.h @@ -2564,7 +2564,7 @@ MG_EXPORT LRESULT GUIAPI PostSyncMessage (HWND hWnd, UINT nMsg, WPARAM wParam, L * * \sa PostSyncMessage */ -MG_EXPORT int GUIAPI SendAsyncMessage (HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam); +MG_EXPORT LRESULT GUIAPI SendAsyncMessage (HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam); #endif /** @@ -2728,7 +2728,7 @@ MG_EXPORT BOOL GUIAPI TranslateKeyMsgToChar (int message, WPARAM wParam, LPARAM lParam, WORD *ch); /** - * \fn int DispatchMessage (PMSG pMsg) + * \fn LRESULT DispatchMessage (PMSG pMsg) * \brief Dispatches a message to the window's callback procedure. * * This function dispatches the message pointed to by \a pMsg to the @@ -2743,7 +2743,7 @@ MG_EXPORT BOOL GUIAPI TranslateKeyMsgToChar (int message, * * \include getmessage.c */ -MG_EXPORT int GUIAPI DispatchMessage (PMSG pMsg); +MG_EXPORT LRESULT GUIAPI DispatchMessage (PMSG pMsg); /** * \fn int ThrowAwayMessages (HWND pMainWnd) diff --git a/src/control/button.c b/src/control/button.c index 77df4f44..6ac04144 100644 --- a/src/control/button.c +++ b/src/control/button.c @@ -941,8 +941,9 @@ static LRESULT ButtonCtrlProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara case MSG_LBUTTONDOWN: if (GetCapture () == hWnd) break; + SetCapture (hWnd); - + BUTTON_STATUS(pctrl) |= BST_FOCUS; change_status_from_pose(pctrl, BST_PUSHED, TRUE, TRUE); break; diff --git a/src/gui/window.c b/src/gui/window.c index 8fed0a13..20e2c2e5 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -2761,7 +2761,7 @@ HWND GUIAPI SetCapture (HWND hWnd) HWND GUIAPI GetCapture (void) { - return (HWND) SendMessage (HWND_DESKTOP, MSG_GETCAPTURE, 0, 0); + return (HWND)SendMessage (HWND_DESKTOP, MSG_GETCAPTURE, 0, 0); } void GUIAPI ReleaseCapture (void) diff --git a/src/kernel/desktop-comm.c b/src/kernel/desktop-comm.c index 608760a8..51d48d46 100644 --- a/src/kernel/desktop-comm.c +++ b/src/kernel/desktop-comm.c @@ -870,7 +870,6 @@ static HWND DesktopSetCapture (HWND hwnd) hTemp = __mg_capture_wnd; __mg_capture_wnd = hwnd; - return hTemp; } diff --git a/src/kernel/desktop-ths.c b/src/kernel/desktop-ths.c index 638aa9f9..b945c0ab 100644 --- a/src/kernel/desktop-ths.c +++ b/src/kernel/desktop-ths.c @@ -122,7 +122,7 @@ void* DesktopMain (void* data) /* process messages of desktop thread */ while (GetMessage(&Msg, HWND_DESKTOP)) { - int iRet = 0; + LRESULT lRet = 0; #ifdef _MGHAVE_TRACE_MSG fprintf (stderr, "Message, %s: hWnd: %p, wP: %#lx, lP: %#lx. %s\n", @@ -133,19 +133,19 @@ void* DesktopMain (void* data) Msg.pAdd?"Sync":"Normal"); #endif - iRet = DesktopWinProc (HWND_DESKTOP, + lRet = DesktopWinProc (HWND_DESKTOP, Msg.message, Msg.wParam, Msg.lParam); if (Msg.pAdd) /* this is a sync message. */ { PSYNCMSG pSyncMsg = (PSYNCMSG)(Msg.pAdd); - pSyncMsg->retval = iRet; + pSyncMsg->retval = lRet; sem_post(pSyncMsg->sem_handle); } #ifdef _MGHAVE_TRACE_MSG - fprintf (stderr, "Message, %s done, return value: %#x\n", - Message2Str (Msg.message), iRet); + fprintf (stderr, "Message, %s done, return value: %lx\n", + Message2Str (Msg.message), lRet); #endif } diff --git a/src/kernel/message.c b/src/kernel/message.c index 96a5d6ac..72983a89 100644 --- a/src/kernel/message.c +++ b/src/kernel/message.c @@ -1018,13 +1018,13 @@ int GUIAPI PostQuitMessage (HWND hWnd) #include "license.h" -int GUIAPI DispatchMessage (PMSG pMsg) +LRESULT GUIAPI DispatchMessage (PMSG pMsg) { WNDPROC WndProc; #ifdef _MGRM_THREADS PSYNCMSG pSyncMsg; #endif - int iRet; + LRESULT lRet; LICENSE_MODIFY_MESSAGE(pMsg); @@ -1059,23 +1059,23 @@ int GUIAPI DispatchMessage (PMSG pMsg) if (!(WndProc = GetWndProc (pMsg->hwnd))) return -1; - iRet = (*WndProc)(pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam); + lRet = WndProc (pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam); #ifdef _MGRM_THREADS /* this is a sync message. */ if (pMsg->pAdd) { pSyncMsg = (PSYNCMSG)pMsg->pAdd; - pSyncMsg->retval = iRet; + pSyncMsg->retval = lRet; sem_post (pSyncMsg->sem_handle); } #endif #ifdef _MGHAVE_TRACE_MSG - fprintf (stderr, "Message, %s done, return value: %x\n", - Message2Str (pMsg->message), iRet); + fprintf (stderr, "Message, %s done, return value: %lx\n", + Message2Str (pMsg->message), lRet); #endif - return iRet; + return lRet; } /* define this to print debug info of ThrowAwayMessages */ @@ -1352,16 +1352,16 @@ LRESULT GUIAPI PostSyncMessage (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara return SendSyncMessage (hWnd, msg, wParam, lParam); } -int GUIAPI SendAsyncMessage (HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam) +LRESULT GUIAPI SendAsyncMessage (HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam) { WNDPROC WndProc; MG_CHECK_RET (MG_IS_WINDOW(hWnd), -1); - if ( !(WndProc = GetWndProc(hWnd)) ) + if (!(WndProc = GetWndProc(hWnd))) return -1; - return (*WndProc)(hWnd, nMsg, wParam, lParam); + return WndProc (hWnd, nMsg, wParam, lParam); } #endif /* !LITE_VERSION */ diff --git a/src/misc/about.c b/src/misc/about.c index 500e0ef4..d5939af5 100644 --- a/src/misc/about.c +++ b/src/misc/about.c @@ -135,12 +135,6 @@ static void* AboutDialogThread (void* data) ShowWindow (hMainWnd, SW_SHOWNORMAL); while (GetMessage(&Msg, hMainWnd)) { - printf ("AboutDialogBox Message, %s: hWnd: %p, wP: %lx, lP: %lx.\n", - Message2Str (Msg.message), - Msg.hwnd, - Msg.wParam, - Msg.lParam); - DispatchMessage(&Msg); }