diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-11-14 19:35:45 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-11-14 19:35:45 +0100 |
commit | df5520aa2dae5b3ce7abf8733dcdd152898af163 (patch) | |
tree | 00d3047bfb14f682bfb5a21010c731ed649bfed7 /app/wlib/mswlib/mswmisc.c | |
parent | df247efec654e512242e4f4f1b0212034f9e01fe (diff) | |
parent | ec3c0f6f6e7153fa797dc57a0e95779cbc63a23b (diff) |
Merge branch 'release/debian/1_5.3.0GA-1'debian/1_5.3.0GA-1
Diffstat (limited to 'app/wlib/mswlib/mswmisc.c')
-rw-r--r-- | app/wlib/mswlib/mswmisc.c | 882 |
1 files changed, 432 insertions, 450 deletions
diff --git a/app/wlib/mswlib/mswmisc.c b/app/wlib/mswlib/mswmisc.c index 6b5f1c9..4bf9481 100644 --- a/app/wlib/mswlib/mswmisc.c +++ b/app/wlib/mswlib/mswmisc.c @@ -17,21 +17,20 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #define _WIN32_WINNT 0x0500 #include <windows.h> #include <shellapi.h> #include <string.h> -#include <malloc.h> +#include <malloc.h> // required for heapinfo in function wMemStats #include <stdlib.h> #include <commdlg.h> #include <math.h> #include <stdio.h> #include <assert.h> #include <htmlhelp.h> -#include "misc.h" #include "mswint.h" #include "i18n.h" #include "FreeImage.h" @@ -45,6 +44,7 @@ #define OFN_LONGFILENAMES 0x00200000L char * mswStrdup(const char *); +const char * GetCurCommandName(void); #define PAUSE_TIMER (901) #define ALARM_TIMER (902) @@ -61,15 +61,14 @@ char * mswStrdup(const char *); #define LABELFONTRESET #else #define LABELFONTDECL HFONT hFont; -#define LABELFONTRESET if (!mswThickFont) {SelectObject( hDc, hFont );} -#define LABELFONTSELECT if (!mswThickFont) {hFont = SelectObject( hDc, mswLabelFont );} +#define LABELFONTRESET SelectObject( hDc, hFont ); +#define LABELFONTSELECT hFont = SelectObject( hDc, mswLabelFont ); #endif /* * EXPORTED VARIABLES */ -long debugWindow = 0; HINSTANCE mswHInst; HWND mswHWnd = (HWND)0; @@ -77,37 +76,40 @@ const char *mswDrawWindowClassName = "DRAWWINDOW"; char mswTmpBuff[1024]; int mswEditHeight; int mswAllowBalloonHelp = TRUE; -int mswGroupStyle; HFONT mswOldTextFont; HFONT mswLabelFont; -long mswThickFont = 1; double mswScale = 1.0; -double scaleIcon = 1.0; /**< Scaling factor for toolbar icons */ - callBacks_t *mswCallBacks[CALLBACK_CNT]; -void closeBalloonHelp(void); +void closeBalloonHelp(int inx); static wControl_p getControlFromCursor(HWND, wWin_p *); + +#ifdef BALLOON_TRACE +// To use: +// change logFile defn in lprintf.c from static to EXPORT +// Run with some debug flag set to ensure logFile is set +extern FILE * logFile; +#endif /* * LOCAL VARIABLES */ struct wWin_t { - WOBJ_COMMON - int validGeometry; - int min_width; - int max_width; - int min_height; - int max_height; - wPos_t lastX, lastY; - wPos_t padX, padY; + WOBJ_COMMON + int validGeometry; + int min_width; + int max_width; + int min_height; + int max_height; + wWinPix_t lastX, lastY; + wWinPix_t padX, padY; wControl_p first, last; wWinCallBack_p winProc; BOOL_T busy; #ifdef OWNERICON HBITMAP wicon_bm; - wPos_t wicon_w, wicon_h; + wWinPix_t wicon_w, wicon_h; #endif DWORD baseStyle; wControl_p focusChainFirst; @@ -131,15 +133,15 @@ static int mResizeBorderH; static int mMenuH; static int screenWidth = 0, screenHeight = 0; -wWin_p mswWin = NULL; -wWin_p winFirst, winLast; +static wWin_p mswWin = NULL; +static wWin_p winFirst, winLast; static long count51 = 0; -static UINT alarmTimer; -static UINT pauseTimer; -static UINT balloonHelpTimer = (UINT)0; -static UINT triggerTimer; +static UINT_PTR alarmTimer; +static UINT_PTR pauseTimer; +static UINT_PTR balloonHelpTimer = (UINT_PTR)0; +static UINT_PTR triggerTimer; static UINT balloonHelpTimeOut = 500; static wControl_p balloonHelpButton = NULL; @@ -160,7 +162,7 @@ static DWORD dwCookie; typedef struct { wControl_p b; } controlMap_t; -dynArr_t controlMap_da; +static dynArr_t controlMap_da; #define controlMap(N) DYNARR_N(controlMap_t,controlMap_da,N) @@ -170,15 +172,11 @@ char *mswProfileFile; static wBalloonHelp_t * balloonHelpStrings; -static wCursor_t curCursor = wCursorNormal; - #ifdef HELPSTR static FILE * helpStrF; #endif static int inMainWndProc = FALSE; -int newHelp = 1; - static wBool_t mswWinBlockEnabled = TRUE; static FILE * dumpControlsF; @@ -187,19 +185,21 @@ static int dumpControls; extern char *userLocale; // list of supported fileformats for image files -char * filterImageFiles[] = { N_("All image files"), - "*.gif;*.jpg;*.jpeg;*.png;*.tif;*.tiff", - N_("GIF files (*.gif)"), - "*.gif", - N_("JPEG files (*.jpeg,*.jpg)"), - "*.jpg;*.jpeg", - N_("PNG files (*.png)"), - "*.png", - N_("TIFF files (*.tiff, *.tif)"), - "*.tif;*.tiff", - N_("All files (*)"), - "*", - }; +static char * filterImageFiles[] = { N_("All image files"), + "*.gif;*.jpg;*.jpeg;*.png;*.tif;*.tiff", + N_("GIF files (*.gif)"), + "*.gif", + N_("JPEG files (*.jpeg,*.jpg)"), + "*.jpg;*.jpeg", + N_("PNG files (*.png)"), + "*.png", + N_("TIFF files (*.tiff, *.tif)"), + "*.tif;*.tiff", + N_("All files (*)"), + "*", + }; + +static HICON hWindowIcon; /* ***************************************************************************** @@ -251,8 +251,8 @@ static void doDumpControls(void) b = controlMap(inx).b; if (b) { - fprintf(dumpControlsF, "[%0.3d] [%x] %s %s %s\n", inx, - (unsigned int)b->hWnd, + fprintf(dumpControlsF, "[%0.3d] [%p] %s %s %s\n", inx, + b->hWnd, (b->type>=0&&b->type<=B_BOX?controlNames[b->type]:"NOTYPE"), (b->labelStr?b->labelStr:"<NULL>"), (b->helpStr?b->helpStr:"<NULL>")); @@ -303,7 +303,8 @@ void mswRepaintLabel(HWND hWnd, wControl_p b) LABELFONTSELECT newBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); oldBrush = SelectObject(hDc, newBrush); - dw = GetTextExtent(hDc, CAST_AWAY_CONST b->labelStr, strlen(b->labelStr)); + dw = GetTextExtent(hDc, CAST_AWAY_CONST b->labelStr, + (int)(strlen(b->labelStr))); rect.left = b->labelX; rect.top = b->labelY; rect.right = b->labelX + LOWORD(dw); @@ -313,7 +314,8 @@ void mswRepaintLabel(HWND hWnd, wControl_p b) /*SetBkMode( hDc, OPAQUE );*/ SetBkColor(hDc, GetSysColor(COLOR_BTNFACE)); - if (!TextOut(hDc, b->labelX, b->labelY, b->labelStr, strlen(b->labelStr))) { + if (!TextOut(hDc, b->labelX, b->labelY, b->labelStr, + (int)(strlen(b->labelStr)))) { mswFail("Repainting text label"); } @@ -376,14 +378,16 @@ void * mswAlloc( w->data = data; w->focusChainNext = NULL; w->shown = TRUE; + w->hilite = FALSE; + w->errStr = NULL; return w; } void mswComputePos( wControl_p b, - wPos_t origX, - wPos_t origY) + wWinPix_t origX, + wWinPix_t origY) { wWin_p w = b->parent; @@ -403,14 +407,14 @@ void mswComputePos( b->labelY = b->y+2; if (b->labelStr) { - int lab_l; + size_t lab_l; HDC hDc; DWORD dw; LABELFONTDECL hDc = GetDC(w->hWnd); LABELFONTSELECT lab_l = strlen(b->labelStr); - dw = GetTextExtent(hDc, CAST_AWAY_CONST b->labelStr, lab_l); + dw = GetTextExtent(hDc, CAST_AWAY_CONST b->labelStr, (UINT)lab_l); b->labelX -= LOWORD(dw) + 5; LABELFONTRESET ReleaseDC(w->hWnd, hDc); @@ -557,7 +561,7 @@ void mswSetFocus( b->parent->focusChainNext = b; } } - + /* ****************************************************************************** * @@ -569,10 +573,10 @@ void mswSetFocus( static void getSavedSizeAndPos( long option, const char * nameStr, - wPos_t *rw, - wPos_t *rh, - wPos_t *rx, - wPos_t *ry, + wWinPix_t *rw, + wWinPix_t *rh, + wWinPix_t *rx, + wWinPix_t *ry, int *showCmd) { char *cq; @@ -580,14 +584,29 @@ static void getSavedSizeAndPos( if ((option&F_RECALLPOS) && nameStr) { int x, y, w, h; + int xadj, yadj; const char *cp; int state; + w = h = 0; + xadj = 1; + yadj = mTitleH + 1; + if (option & F_RESIZE) { + xadj += mResizeBorderW * 2; + yadj += mResizeBorderH * 2; + } else { + xadj += mFixBorderW * 2; + yadj += mFixBorderH * 2; + } + //if (option & F_MENUBAR) { + // yadj += mMenuH; + //} + if ((option & F_RESIZE) && (cp = wPrefGetStringBasic("msw window size", nameStr)) && - (state = (int)strtol(cp, &cq, 10), cp != cq) && // state is not used - (cp = cq, w = (wPos_t)strtod(cp, &cq), cp != cq) && - (cp = cq, h = (int)strtod(cp, &cq), cp != cq) + (state = (int)strtol(cp, &cq, 10), cp != cq) && // state is not used + (cp = cq, w = (wWinPix_t)(strtod(cp, &cq)), cp != cq) && + (cp = cq, h = (wWinPix_t)(strtod(cp, &cq)), cp != cq) ) { if (w < 10) { w = 10; @@ -597,12 +616,12 @@ static void getSavedSizeAndPos( h = 10; } - if (w > screenWidth) { - w = screenWidth; + if (w > screenWidth - xadj) { + w = screenWidth - xadj; } - if (h > screenHeight) { - h = screenHeight; + if (h > screenHeight - yadj) { + h = screenHeight - yadj; } *rw = w; @@ -610,8 +629,8 @@ static void getSavedSizeAndPos( } if ((cp = wPrefGetStringBasic("msw window pos", nameStr)) && - (x = (wPos_t)strtod(cp, &cq), cp != cq) && - (cp = cq, y = (wPos_t)strtod(cp, &cq), cp != cq) + (x = (wWinPix_t)(strtod(cp, &cq)), cp != cq) && + (cp = cq, y = (wWinPix_t)(strtod(cp, &cq)), cp != cq) ) { if (y < 0) { y = 0; @@ -621,12 +640,17 @@ static void getSavedSizeAndPos( x = 0; } - if (y > screenHeight-40) { - y = screenHeight-40; + // Make sure we can see the dialog + xadj += 100; + yadj += 100; + + + if (y + h > screenHeight - yadj) { + y = screenHeight - yadj - h; } - if (x > screenWidth-40) { - x = screenWidth-40; + if (x + w > screenWidth - xadj) { + x = screenWidth - xadj - w; } *rx = x; @@ -636,7 +660,7 @@ static void getSavedSizeAndPos( } /** - * Set min and max dimensions for a window. + * Set min and max dimensions for a window. * * \param min_width IN minimum width of window * \param max_width IN maximum width of window @@ -647,21 +671,21 @@ static void getSavedSizeAndPos( * \param aspect_ration IN unused on Windows */ void wSetGeometry(wWin_p win, - int min_width, - int max_width, - int min_height, - int max_height, - int base_width, - int base_height, - double aspect_ratio) + wWinPix_t min_width, + wWinPix_t max_width, + wWinPix_t min_height, + wWinPix_t max_height, + wWinPix_t base_width, + wWinPix_t base_height, + double aspect_ratio) { - win->validGeometry = TRUE; //remember that geometry was set - win->min_width = min_width; - win->max_width = max_width; - win->min_height = min_height; - win->max_height = max_height; + win->validGeometry = TRUE; //remember that geometry was set + win->min_width = min_width; + win->max_width = max_width; + win->min_height = min_height; + win->max_height = max_height; - return; + return; } /** @@ -671,13 +695,13 @@ void wSetGeometry(wWin_p win, * \param typ IN type of window (W_MAIN or W_POPUP) * \param option IN options for window creation * \param classname IN pre-registered window class - * \param style IN + * \param style IN * \param labelStr IN window title * \param winProc IN callback procedure * \param w IN default window width * \param h IN default window height * \param data IN ?? - * \param nameStr IN name of window + * \param nameStr IN name of window * \param pShowCmd IN/OUT window show option (maximize or show normal) * \return window data structure */ @@ -690,15 +714,15 @@ static wWin_p winCommonCreate( long style, const char * labelStr, wWinCallBack_p winProc, - wPos_t w, - wPos_t h, + wWinPix_t w, + wWinPix_t h, void * data, const char * nameStr, int * pShowCmd) { wWin_p win; int index; - wPos_t ww, hh, xx, yy; + wWinPix_t ww, hh, xx, yy; RECT rect; win = (wWin_p)mswAlloc(NULL, typ, mswStrdup(labelStr), sizeof *win, data, &index); @@ -715,6 +739,8 @@ static wWin_p winCommonCreate( if (typ == W_MAIN) { *pShowCmd = ((option & F_MAXIMIZE) ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL); + } else { + *pShowCmd = SW_HIDE; //Make sure to hide first } if (xx != CW_USEDEFAULT) { @@ -774,6 +800,10 @@ static wWin_p winCommonCreate( win->nameStr = mswStrdup(nameStr); + //HICON hIcon1 = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(101), IMAGE_ICON, 32, 32, LR_DEFAULTSIZE); + SendMessage(win->hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hWindowIcon); + SendMessage(win->hWnd, WM_SETICON, ICON_BIG, (LPARAM)hWindowIcon); + if (typ == W_MAIN) { mswInitColorPalette(); } @@ -806,8 +836,8 @@ void wInitAppName(char *_appName) wWin_p wWinMainCreate( const char * name, - POS_T x, - POS_T y, + wWinPix_t x, + wWinPix_t y, const char * helpStr, const char * labelStr, const char * nameStr, @@ -816,7 +846,6 @@ wWin_p wWinMainCreate( void * data) { wWin_p w; - RECT rect; const char * appDir; const char * libDir; int showCmd; @@ -825,7 +854,7 @@ wWin_p wWinMainCreate( TEXTMETRIC tm; char *pos; char * configName; - long maximize; + long maximize; /* check for configuration name */ if (pos = strchr(name, ';')) { @@ -862,14 +891,9 @@ wWin_p wWinMainCreate( /* length of path + \ + length of filename + . + length of extension + \0 */ helpFile = (char*)malloc(strlen(libDir) + 1 + strlen(appName) + 1 + 3 + 1); wsprintf(helpFile, "%s\\%s.chm", libDir, appName); - wPrefGetInteger("msw tweak", "ThickFont", &mswThickFont, 0); - wPrefGetInteger("draw", "maximized", &maximize, 0L); - option |= (maximize ? F_MAXIMIZE : 0); - - wPrefGetFloat(PREFSECTION, LARGEICON, &scaleIcon, 1.0); - if (scaleIcon < 1.0) scaleIcon = 1.0; - if (scaleIcon > 2.0) scaleIcon = 2.0; + wPrefGetInteger("draw", "maximized", &maximize, 0L); + option |= (maximize ? F_MAXIMIZE : 0); showCmd = SW_SHOW; w = winCommonCreate(NULL, W_MAIN, option|F_RESIZE, "MswMainWindow", @@ -877,26 +901,22 @@ wWin_p wWinMainCreate( nameStr, &showCmd); mswHWnd = w->hWnd; - if (!mswThickFont) { - SendMessage(w->hWnd, WM_SETFONT, (WPARAM)mswLabelFont, 0L); - hDc = GetDC(w->hWnd); - GetTextMetrics(hDc, &tm); - mswEditHeight = tm.tmHeight+2; - ReleaseDC(w->hWnd, hDc); - } + SendMessage(mswHWnd, WM_SETFONT, (WPARAM)mswLabelFont, (LPARAM)0); + hDc = GetDC(mswHWnd); + GetTextMetrics(hDc, &tm); + mswEditHeight = tm.tmHeight+2; + ReleaseDC(mswHWnd, hDc); - ShowWindow(w->hWnd, showCmd); - UpdateWindow(w->hWnd); - GetWindowRect(w->hWnd, &rect); - GetClientRect(w->hWnd, &rect); + ShowWindow(mswHWnd, showCmd); + UpdateWindow(mswHWnd); w->busy = FALSE; return w; } wWin_p wWinPopupCreate( wWin_p parent, - POS_T x, - POS_T y, + wWinPix_t x, + wWinPix_t y, const char * helpStr, const char * labelStr, const char * nameStr, @@ -1077,7 +1097,7 @@ static wAccelKey_e translateExtKey(UINT wParam) } -long notModKey; +static long notModKey; int mswTranslateAccelerator( HWND hWnd, LPMSG pMsg) @@ -1091,7 +1111,7 @@ int mswTranslateAccelerator( return FALSE; } - acclKey = pMsg->wParam; + acclKey = (long)pMsg->wParam; b = getControlFromCursor(pMsg->hwnd, &win); if (win == NULL) { @@ -1112,7 +1132,7 @@ int mswTranslateAccelerator( } if (acclKey == (long)VK_F1) { - closeBalloonHelp(); + closeBalloonHelp(1); if (!b && win) { wHelp(win->helpStr); @@ -1162,14 +1182,14 @@ int mswTranslateAccelerator( -void wGetDisplaySize(POS_T * width, POS_T * height) +void wGetDisplaySize(wWinPix_t * width, wWinPix_t * height) { *width = screenWidth; *height = screenHeight; } -void wWinGetSize(wWin_p w, POS_T * width, POS_T * height) +void wWinGetSize(wWin_p w, wWinPix_t * width, wWinPix_t * height) { RECT rect; GetWindowRect(w->hWnd, &rect); @@ -1181,7 +1201,7 @@ void wWinGetSize(wWin_p w, POS_T * width, POS_T * height) } -void wWinSetSize(wWin_p w, POS_T width, POS_T height) +void wWinSetSize(wWin_p w, wWinPix_t width, wWinPix_t height) { RECT rect; w->w = width; @@ -1224,33 +1244,24 @@ static void blockingLoop(void) static void savePos(wWin_p win) { - WINDOWPLACEMENT windowPlace; - wPos_t w, h; + wWinPix_t w, h; RECT rect; if (win->nameStr && IsWindowVisible(win->hWnd) /*&& !IsIconic( win->hWnd )*/) { - windowPlace.length = sizeof windowPlace; - GetWindowPlacement(win->hWnd, &windowPlace); + GetWindowRect(win->hWnd, &rect); if (win->option&F_RECALLPOS) { char posStr[20]; wsprintf(posStr, "%d %d", - windowPlace.rcNormalPosition.left, - windowPlace.rcNormalPosition.top); + rect.left, + rect.top); wPrefSetString("msw window pos", win->nameStr, posStr); if (win->option&F_RESIZE) { GetClientRect(win->hWnd, &rect); - w = windowPlace.rcNormalPosition.right - windowPlace.rcNormalPosition.left; - h = windowPlace.rcNormalPosition.bottom - windowPlace.rcNormalPosition.top; - w -= mResizeBorderW*2; - h -= mResizeBorderH*2 + mTitleH; - - if (win->option&F_MENUBAR) { - h -= mMenuH; - } - + w = rect.right - rect.left; + h = rect.bottom - rect.top; wsprintf(posStr, "%d %d %d", 0, // unused w, h); @@ -1265,7 +1276,7 @@ void wWinShow( wWin_p win, BOOL_T show) { - wPos_t x, y; + wWinPix_t x, y; wWin_p win1; win->busy = TRUE; @@ -1292,6 +1303,11 @@ void wWinShow( win->centerWin = FALSE; win->shown = TRUE; + // Clear hilites + for (wControl_p controlP = win->first; controlP; controlP = controlP->next) { + controlP->hilite = FALSE; + } + if (mswHWnd == (HWND)0 || !IsIconic(mswHWnd)) { ShowWindow(win->hWnd, SW_SHOW); @@ -1429,73 +1445,13 @@ const char * wWinGetTitle( void wWinClear( wWin_p win, - wPos_t x, - wPos_t y, - wPos_t width, - wPos_t height) + wWinPix_t x, + wWinPix_t y, + wWinPix_t width, + wWinPix_t height) { } -void wSetCursor(wDraw_p win, - wCursor_t cursor) -{ - switch (cursor) { - case wCursorNormal: - default: - SetCursor(LoadCursor(NULL, IDC_ARROW)); - break; - - case wCursorWait: - SetCursor(LoadCursor(NULL, IDC_WAIT)); - break; - - case wCursorCross: - SetCursor(LoadCursor(NULL, IDC_CROSS)); - break; - - case wCursorIBeam: - SetCursor(LoadCursor(NULL, IDC_IBEAM)); - break; - - case wCursorQuestion: - SetCursor(LoadCursor(NULL, IDC_HELP)); - break; - - case wCursorHand: - SetCursor(LoadCursor(NULL, IDC_HAND)); - break; - - case wCursorNo: - SetCursor(LoadCursor(NULL, IDC_NO)); - break; - - case wCursorSizeAll: - SetCursor(LoadCursor(NULL, IDC_SIZEALL)); - break; - - case wCursorSizeNESW: - SetCursor(LoadCursor(NULL, IDC_SIZENESW)); - break; - - case wCursorSizeNWSE: - SetCursor(LoadCursor(NULL, IDC_SIZENWSE)); - break; - - case wCursorSizeNS: - SetCursor(LoadCursor(NULL, IDC_SIZENS)); - break; - - case wCursorSizeWE: - SetCursor(LoadCursor(NULL, IDC_SIZEWE)); - break; - - case wCursorAppStart: - SetCursor(LoadCursor(NULL, IDC_APPSTARTING)); - break; - } - - curCursor = cursor; -} void wWinDoCancel(wWin_p win) { @@ -1667,44 +1623,44 @@ const char * wControlGetHelp(wControl_p b) } -wPos_t wLabelWidth(const char * labelStr) +wWinPix_t wLabelWidth(const char * labelStr) { - int lab_l; + size_t lab_l; HDC hDc; DWORD dw; LABELFONTDECL hDc = GetDC(mswHWnd); lab_l = strlen(labelStr); LABELFONTSELECT - dw = GetTextExtent(hDc, CAST_AWAY_CONST labelStr, lab_l); + dw = GetTextExtent(hDc, CAST_AWAY_CONST labelStr, (UINT)lab_l); LABELFONTRESET ReleaseDC(mswHWnd, hDc); return LOWORD(dw) + 5; } -wPos_t wControlGetWidth( +wWinPix_t wControlGetWidth( wControl_p b) /* Control */ { return b->w; } -wPos_t wControlGetHeight( +wWinPix_t wControlGetHeight( wControl_p b) /* Control */ { return b->h; } -wPos_t wControlGetPosX( +wWinPix_t wControlGetPosX( wControl_p b) /* Control */ { return b->x; } -wPos_t wControlGetPosY( +wWinPix_t wControlGetPosY( wControl_p b) /* Control */ { return b->y; @@ -1713,21 +1669,21 @@ wPos_t wControlGetPosY( void wControlSetPos( wControl_p b, - wPos_t x, - wPos_t y) + wWinPix_t x, + wWinPix_t y) { b->labelX = x; b->labelY = y+2; if (b->labelStr) { - int lab_l; + size_t lab_l; HDC hDc; DWORD dw; LABELFONTDECL hDc = GetDC(b->parent->hWnd); LABELFONTSELECT lab_l = strlen(b->labelStr); - dw = GetTextExtent(hDc, CAST_AWAY_CONST b->labelStr, lab_l); + dw = GetTextExtent(hDc, CAST_AWAY_CONST b->labelStr, (UINT)lab_l); b->labelX -= LOWORD(dw) + 5; LABELFONTRESET ReleaseDC(b->parent->hWnd, hDc); @@ -1757,14 +1713,14 @@ void wControlSetLabel( if (b->type == B_RADIO ) { ; } else { - int lab_l; + size_t lab_l; HDC hDc; DWORD dw; LABELFONTDECL hDc = GetDC(b->parent->hWnd); lab_l = strlen(labelStr); LABELFONTSELECT - dw = GetTextExtent(hDc, CAST_AWAY_CONST labelStr, lab_l); + dw = GetTextExtent(hDc, CAST_AWAY_CONST labelStr, (UINT)lab_l); LABELFONTRESET b->labelX = b->x - LOWORD(dw) - 5; ReleaseDC(b->parent->hWnd, hDc); @@ -1791,33 +1747,36 @@ void wControlHilite( HDC hDc; HPEN oldPen, newPen; int oldMode; - LOGBRUSH logBrush = { BS_SOLID, CONTROLHILITECOLOR, (ULONG_PTR)NULL }; + LOGBRUSH logBrush = { BS_SOLID, CONTROLHILITECOLOR, (ULONG_PTR)NULL }; if (b == NULL) { return; } - if (!IsWindowVisible(b->parent->hWnd)) { + if ((b->parent==NULL) || (!IsWindowVisible(b->parent->hWnd)) + || (!IsWindowVisible(b->hWnd))) { + b->hilite = FALSE; return; } - if (!IsWindowVisible(b->hWnd)) { + if (b->hilite == hilite) { return; } + b->hilite = hilite; hDc = GetDC(b->parent->hWnd); - newPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND | PS_JOIN_BEVEL, - CONTROLHILITEWIDTH, - &logBrush, - 0, - NULL); + newPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_ROUND | PS_JOIN_BEVEL, + CONTROLHILITEWIDTH, + &logBrush, + 0, + NULL); oldPen = SelectObject(hDc, newPen); oldMode = SetROP2(hDc, R2_NOTXORPEN); - Rectangle(hDc, - b->x - CONTROLHILITEWIDTH - 1, - b->y - CONTROLHILITEWIDTH - 1, - b->x + b->w + CONTROLHILITEWIDTH + 1, - b->y + b->h + CONTROLHILITEWIDTH + 1); + Rectangle(hDc, + b->x - CONTROLHILITEWIDTH - 1, + b->y - CONTROLHILITEWIDTH - 1, + b->x + b->w + CONTROLHILITEWIDTH + 1, + b->y + b->h + CONTROLHILITEWIDTH + 1); SetROP2(hDc, oldMode); SelectObject(hDc, oldPen); DeleteObject(newPen); @@ -1840,7 +1799,7 @@ void wMessage( { HDC hDc; int oldRop; - POS_T h; + wWinPix_t h; RECT rect; LABELFONTDECL @@ -1855,30 +1814,30 @@ void wMessage( Rectangle(hDc, 0, h, w->w, h); SetROP2(hDc, oldRop); LABELFONTSELECT - TextOut(hDc, 0, h, msg, strlen(msg)); + TextOut(hDc, 0, h, msg, (int)(strlen(msg))); LABELFONTRESET ReleaseDC(w->hWnd, hDc); } /** * Open a document using an external application - * + * * \param file * \return TRUE on success, FALSE on error - * + * */ unsigned wOpenFileExternal(char *file) { - HINSTANCE res; + HINSTANCE res; - res = ShellExecute(mswHWnd, "open", file, NULL, NULL, SW_SHOW); + res = ShellExecute(mswHWnd, "open", file, NULL, NULL, SW_SHOW); - if ((int)res <= 32) { - wNoticeEx(NT_ERROR, "Error when opening file!", "Cancel", NULL); - return(FALSE); - } + if ((UINT_PTR)res <= 32) { + wNoticeEx(NT_ERROR, "Error when opening file!", "Cancel", NULL); + return(FALSE); + } - return(TRUE); + return(TRUE); } void wExit(int rc) @@ -1886,7 +1845,6 @@ void wExit(int rc) INDEX_T inx; wControl_p b; mswPutCustomColors(); - wPrefFlush(); for (inx=controlMap_da.cnt-1; inx>=0; inx--) { b = controlMap(inx).b; @@ -1903,6 +1861,8 @@ void wExit(int rc) } } + wPrefFlush(""); + for (inx=controlMap_da.cnt-1; inx>=0; inx--) { b = controlMap(inx).b; @@ -1923,7 +1883,7 @@ void wExit(int rc) } if (helpInitted) { - WinHelp(mswHWnd, helpFile, HELP_QUIT, 0L); + WinHelp(mswHWnd, helpFile, HELP_QUIT, (DWORD)0); helpInitted = FALSE; } @@ -2155,7 +2115,7 @@ int wNotice3( } /** - * Show help text for the given topic. + * Show help text for the given topic. * * \param topic The topic. if NULL the index page is shown. */ @@ -2165,14 +2125,14 @@ void wHelp( { char *pszHelpTopic; HWND hwndHelp; - char *theTopic = "index"; + const char *theTopic = "index"; - if (topic) { - theTopic = topic; - } + if (topic) { + theTopic = topic; + } if (!helpInitted) { - HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD)&dwCookie) ; + HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD_PTR)&dwCookie) ; helpInitted = TRUE; } @@ -2199,11 +2159,12 @@ void doHelpMenu(void * context) HH_FTS_QUERY ftsQuery; if (!helpInitted) { - HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD)&dwCookie) ; + HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD_PTR)&dwCookie) ; helpInitted = TRUE; } - switch ((int)(long)context) { + const char * topic; + switch ((int)(INT_PTR)context) { case 1: /* Contents */ HtmlHelp(mswHWnd, helpFile, HH_DISPLAY_TOC, (DWORD_PTR)NULL); break; @@ -2215,15 +2176,14 @@ void doHelpMenu(void * context) ftsQuery.fTitleOnly = FALSE; ftsQuery.pszSearchQuery = NULL; ftsQuery.pszWindow = NULL; - HtmlHelp(mswHWnd, helpFile, HH_DISPLAY_SEARCH,(DWORD)&ftsQuery); + HtmlHelp(mswHWnd, helpFile, HH_DISPLAY_SEARCH,(DWORD_PTR)&ftsQuery); break; case 3: /*Context*/ - const char * topic; - topic = GetCurCommandName(); - wHelp(topic); - break; + topic = GetCurCommandName(); + wHelp(topic); + break; default: return; @@ -2232,8 +2192,9 @@ void doHelpMenu(void * context) helpInitted = TRUE; } -void wDoAccelHelp(wAccelKey_e key, void * context) { - doHelpMenu(context); +void wDoAccelHelp(wAccelKey_e key, void * context) +{ + doHelpMenu(context); } void wMenuAddHelp( @@ -2267,88 +2228,108 @@ void wControlSetBalloonText(wControl_p b, const char * text) b->tipStr = mswStrdup(text); } - -void startBalloonHelp(void) +void openBalloonHelp(wControl_p b, int dx, int dy) { HDC hDc; DWORD extent; RECT rect; POINT pt; - wBalloonHelp_t * bh; - const char * hs; HFONT hFont; - - if (!balloonHelpStrings) { - return; + const char * msg; + if (b->errStr) { + msg = b->errStr; + } else { + msg = b->tipStr; + if (!balloonHelpEnable) { +#ifdef BALLOON_TRACE + fprintf(logFile, "openBalloon !Enable state %d\n", balloonHelpState); + fflush(logFile); +#endif + return; + } } - - if (!balloonHelpEnable) { +#ifdef BALLOON_TRACE + fprintf(logFile, "openBalloon %s state %d\n", msg, balloonHelpState); + fflush(logFile); +#endif + if (!balloonHelpHWnd) { return; } + int w, h; + hDc = GetDC(balloonHelpHWnd); + hFont = SelectObject(hDc, mswLabelFont); + extent = GetTextExtent(hDc, CAST_AWAY_CONST msg, (int)(strlen(msg))); + w = LOWORD(extent); + h = HIWORD(extent); - if (balloonHelpHWnd) { - if (balloonHelpButton->tipStr) { - hs = balloonHelpButton->tipStr; - } else { - hs = balloonHelpButton->helpStr; - - if (!hs) { - return; - } + if (b->type == B_RADIO || + b->type == B_TOGGLE) { + pt.y = b->h; + } else { + GetClientRect(b->hWnd, &rect); + pt.y = rect.bottom; + } - for (bh = balloonHelpStrings; bh->name && strcmp(bh->name,hs) != 0; bh++); + pt.x = dx; + pt.y -= dy; + ClientToScreen(b->hWnd, &pt); - if (!bh->name || !bh->value) { - return; - } + if (pt.x + w + 2 > screenWidth) { + pt.x = screenWidth - (w + 2); + } - balloonHelpButton->tipStr = hs = bh->value; - } + if (pt.x < 0) { + pt.x = 0; + } - if (newHelp) { - wControlSetBalloon(balloonHelpButton, 0, 0, hs); - } else { - int w, h; - hDc = GetDC(balloonHelpHWnd); - hFont = SelectObject(hDc, mswLabelFont); - extent = GetTextExtent(hDc, CAST_AWAY_CONST hs, strlen(hs)); - w = LOWORD(extent); - h = HIWORD(extent); - pt.x = 0; - - if (balloonHelpButton->type == B_RADIO || - balloonHelpButton->type == B_TOGGLE) { - pt.y = balloonHelpButton->h; - } else { - GetClientRect(balloonHelpButton->hWnd, &rect); - pt.y = rect.bottom; - } + SetWindowPos(balloonHelpHWnd, HWND_TOPMOST, pt.x, pt.y, w + 6, h + 4, + SWP_SHOWWINDOW | SWP_NOACTIVATE); + if (!b->errStr) { + SetBkColor(hDc, GetSysColor(COLOR_INFOBK)); + SetTextColor(hDc, GetSysColor(COLOR_INFOTEXT)); + } else { + SetBkColor(hDc, GetSysColor(COLOR_HIGHLIGHT)); + SetTextColor(hDc, GetSysColor(COLOR_HIGHLIGHTTEXT)); + } + TextOut(hDc, 2, 1, msg, (int)(strlen(msg))); + SelectObject(hDc, hFont); + ReleaseDC(balloonHelpHWnd, hDc); + balloonHelpState = balloonHelpShow; + balloonControlButton = b; +} - ClientToScreen(balloonHelpButton->hWnd, &pt); - if (pt.x + w+2 > screenWidth) { - pt.x = screenWidth-(w+2); - } - if (pt.x < 0) { - pt.x = 0; - } +void startBalloonHelp(void) +{ + wBalloonHelp_t * bh; - SetWindowPos(balloonHelpHWnd, HWND_TOPMOST, pt.x, pt.y, w+6, h+4, - SWP_SHOWWINDOW|SWP_NOACTIVATE); - SetBkColor(hDc, GetSysColor(COLOR_INFOBK)); - TextOut(hDc, 2, 1, hs, strlen(hs)); - SelectObject(hDc, hFont); - ReleaseDC(balloonHelpHWnd, hDc); + if (!balloonHelpButton->tipStr) { + if (!balloonHelpStrings) { + return; + } + for (bh = balloonHelpStrings; bh->name + && strcmp(bh->name, balloonHelpButton->helpStr) != 0; bh++); + if (!bh->name || !bh->value) { + balloonHelpButton->tipStr = _(balloonHelpButton->helpStr); + } else { + balloonHelpButton->tipStr = _(bh->value); } } + + openBalloonHelp(balloonHelpButton, 0, 0); } -void closeBalloonHelp(void) + +void closeBalloonHelp(int inx) { +#ifdef BALLOON_TRACE + fprintf(logFile, "closeBallonHelp %d state=%d\n", inx, balloonHelpState); + fflush(logFile); +#endif if (balloonHelpTimer) { KillTimer(mswHWnd, balloonHelpTimer); - balloonHelpTimer = 0; + balloonHelpTimer = (UINT_PTR)0; } if (balloonHelpState == balloonHelpShow) @@ -2360,56 +2341,26 @@ void closeBalloonHelp(void) } -void wControlSetBalloon(wControl_p b, wPos_t dx, wPos_t dy, const char * msg) +void wControlSetBalloon(wControl_p b, wWinPix_t dx, wWinPix_t dy, + const char * msg) { - HDC hDc; - DWORD extent; - RECT rect; - POINT pt; - HFONT hFont; - if (msg) { - int w, h; - hDc = GetDC(balloonHelpHWnd); - hFont = SelectObject(hDc, mswLabelFont); - extent = GetTextExtent(hDc, CAST_AWAY_CONST msg, strlen(msg)); - w = LOWORD(extent); - h = HIWORD(extent); - - if (b->type == B_RADIO || - b->type == B_TOGGLE) { - pt.y = b->h; - } else { - GetClientRect(b->hWnd, &rect); - pt.y = rect.bottom; + if (b->errStr) { + free(b->errStr); } - - pt.x = dx; - pt.y -= dy; - ClientToScreen(b->hWnd, &pt); - - if (pt.x + w+2 > screenWidth) { - pt.x = screenWidth-(w+2); - } - - if (pt.x < 0) { - pt.x = 0; - } - - SetWindowPos(balloonHelpHWnd, HWND_TOPMOST, pt.x, pt.y, w+6, h+4, - SWP_SHOWWINDOW|SWP_NOACTIVATE); - SetBkColor(hDc, GetSysColor(COLOR_INFOBK)); - TextOut(hDc, 2, 1, msg, strlen(msg)); - SelectObject(hDc, hFont); - ReleaseDC(balloonHelpHWnd, hDc); - balloonHelpState = balloonHelpShow; - balloonControlButton = b; + b->errStr = mswStrdup(msg); + openBalloonHelp(b, dx, dy); } else { - closeBalloonHelp(); + if (b->errStr) { + free(b->errStr); + } + b->errStr = NULL; + closeBalloonHelp(2); } } + int wGetKeyState(void) { int rc, keyState; @@ -2467,19 +2418,20 @@ struct wFilSel_t { char * GetImageFileFormats(void) { - char *filter = malloc(2048); - char *current = filter; - char *message; + char *filter = malloc(2048); + char *current = filter; + char *message; - for (int i = 0; i < sizeof(filterImageFiles) / sizeof(filterImageFiles[0]); i += 2) { - message = gettext(filterImageFiles[i]); - strcpy(current, message); - current += strlen(message) + 1; - strcpy(current, filterImageFiles[i + 1]); - current += strlen(current) + 1; - } - *current = '\0'; - return(filter); + for (int i = 0; i < sizeof(filterImageFiles) / sizeof(filterImageFiles[0]); + i += 2) { + message = gettext(filterImageFiles[i]); + strcpy(current, message); + current += strlen(message) + 1; + strcpy(current, filterImageFiles[i + 1]); + current += strlen(current) + 1; + } + *current = '\0'; + return(filter); } /** @@ -2515,12 +2467,11 @@ int wFilSelect( memset(&ofn, 0, sizeof ofn); ofn.lStructSize = sizeof ofn; ofn.hwndOwner = mswHWnd; - if (fs->option == FS_PICTURES) { - ofn.lpstrFilter = GetImageFileFormats(); - } - else { - ofn.lpstrFilter = fs->extList; - } + if (fs->option == FS_PICTURES) { + ofn.lpstrFilter = GetImageFileFormats(); + } else { + ofn.lpstrFilter = fs->extList; + } ofn.nFilterIndex = 0; selFileName = malloc(SELECTEDFILENAME_BUFFERSIZE); @@ -2613,7 +2564,7 @@ struct wFilSel_t * wFilSelCreate( { char * cp; struct wFilSel_t * ret; - int len; + size_t len; ret = (struct wFilSel_t*)malloc(sizeof *ret); ret->parent = parent; ret->mode = mode; @@ -2671,7 +2622,7 @@ const char * wMemStats(void) ", Unknown Heap Status"); return msg; } - + /* ***************************************************************************** * @@ -2750,8 +2701,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) int inx; wWin_p w; wControl_p b, oldW; - int child = ((GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD) != 0); - POS_T newW, newH; + wWinPix_t newW, newH; RECT rect; PAINTSTRUCT ps; HWND hWnd2; @@ -2759,23 +2709,24 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) HDC hDc; wAccelKey_e extChar; + LPMINMAXINFO pMMI; switch (message) { - case WM_GETMINMAXINFO: - LPMINMAXINFO pMMI = (LPMINMAXINFO)lParam; - inx = GetWindowWord(hWnd, 0); - - if (inx >= CONTROL_BASE && inx <= controlMap_da.cnt) { - w = (wWin_p)controlMap(inx - CONTROL_BASE).b; - if (w != NULL) { - if (w->validGeometry) { - pMMI->ptMaxTrackSize.x = w->max_width; - pMMI->ptMaxTrackSize.y = w->max_height; - pMMI->ptMinTrackSize.x = w->min_width; - pMMI->ptMinTrackSize.y = w->min_height; - } - } - } - return(0); + case WM_GETMINMAXINFO: + pMMI = (LPMINMAXINFO)lParam; + inx = GetWindowWord(hWnd, 0); + + if (inx >= CONTROL_BASE && inx <= controlMap_da.cnt) { + w = (wWin_p)controlMap(inx - CONTROL_BASE).b; + if (w != NULL) { + if (w->validGeometry) { + pMMI->ptMaxTrackSize.x = w->max_width; + pMMI->ptMaxTrackSize.y = w->max_height; + pMMI->ptMinTrackSize.x = w->min_width; + pMMI->ptMinTrackSize.y = w->min_height; + } + } + } + return (LRESULT)0; case WM_MOUSEWHEEL: inx = GetWindowWord(hWnd, 0); @@ -2785,14 +2736,14 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (mswCallBacks[b->type] != NULL && mswCallBacks[b->type]->messageProc) return mswCallBacks[b->type]->messageProc((wControl_p)b, hWnd, - message, wParam, lParam); + message, wParam, lParam); - return (0); + return (LRESULT)0; - case WM_DRAWITEM: case WM_COMMAND: + closeBalloonHelp(3); + case WM_DRAWITEM: case WM_MEASUREITEM: - closeBalloonHelp(); if (WCMD_PARAM_ID < CONTROL_BASE || WCMD_PARAM_ID > (WPARAM)controlMap_da.cnt) { break; @@ -2808,10 +2759,10 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) // draw the bitmap mswDrawIcon(((LPDRAWITEMSTRUCT)lParam)->hDC, 0, 0, (wIcon_p)(b->data), FALSE, (COLORREF)0, (COLORREF)0); - return (TRUE); + return (LRESULT)TRUE; } else { mswSetFocus(b); - ret = 0L; + ret = 0; if (!inMainWndProc) { inMainWndProc = TRUE; @@ -2824,7 +2775,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) inMainWndProc = FALSE; } - return ret; + return (LRESULT)ret; } case WM_PAINT: @@ -2846,7 +2797,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } EndPaint(hWnd, &ps); - return 1L; + return (LRESULT)1; } break; @@ -2876,8 +2827,8 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case SIZE_MAXIMIZED: case SIZE_MINIMIZED: case SIZE_RESTORED: - newW = LOWORD(lParam); - newH = HIWORD(lParam); + newW = LOWORD(lParam); + newH = HIWORD(lParam); if (newW <= 0 || newH <= 0) { break; @@ -2895,8 +2846,8 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (w->winProc) { w->winProc(w, wResize_e, NULL, w->data); - w->winProc(w, wState_e, NULL, w->data); - } + w->winProc(w, wState_e, NULL, w->data); + } break; @@ -2924,7 +2875,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (mswCallBacks[w->type] != NULL && mswCallBacks[w->type]->messageProc) return mswCallBacks[w->type]->messageProc((wControl_p)w, hWnd, - message, wParam, lParam); + message, wParam, lParam); break; } @@ -2942,9 +2893,20 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } b = getControlFromCursor(hWnd, NULL); - closeBalloonHelp(); + closeBalloonHelp(4); if (b && b->type == B_DRAW) { + // Change Num keypad to a special code to emulate cursor keys + if (wParam == VK_UP || + wParam == VK_DOWN || + wParam == VK_RIGHT || + wParam == VK_LEFT || + wParam == VK_INSERT || + wParam == VK_DELETE) { + if ((lParam & 0x1000000) == 0) { + lParam |= 0x1000000; + } + } return SendMessage(b->hWnd, WM_CHAR, wParam, lParam); } @@ -2959,7 +2921,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (mswCallBacks[B_BUTTON] != NULL && mswCallBacks[B_BUTTON]->messageProc) { ret = mswCallBacks[B_BUTTON]->messageProc(b, b->hWnd, - WM_COMMAND, wParam, lParam); + WM_COMMAND, wParam, lParam); } inMainWndProc = FALSE; @@ -2967,7 +2929,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } } - return 0L; + return (LRESULT)0; case 0x1B: @@ -2979,7 +2941,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (mswCallBacks[B_BUTTON] != NULL && mswCallBacks[B_BUTTON]->messageProc) { ret = mswCallBacks[B_BUTTON]->messageProc(b, b->hWnd, - WM_COMMAND, wParam, lParam); + WM_COMMAND, wParam, lParam); } inMainWndProc = FALSE; @@ -2988,7 +2950,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } mswSetTrigger((wControl_p)TRIGGER_TIMER, NULL); - return 0L; + return (LRESULT)0; case 0x20: @@ -3002,7 +2964,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (mswCallBacks[b->type] != NULL && mswCallBacks[b->type]->messageProc) { ret = mswCallBacks[b->type]->messageProc(b, b->hWnd, - WM_COMMAND, MAKELPARAM(LOWORD(wParam), BN_CLICKED), (LPARAM)(b->hWnd)); + WM_COMMAND, MAKELPARAM(LOWORD(wParam), BN_CLICKED), (LPARAM)(b->hWnd)); } inMainWndProc = FALSE; @@ -3010,7 +2972,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } } - return 0L; + return (LRESULT)0; case 0x09: @@ -3041,16 +3003,16 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } } - return 0L; + return (LRESULT)0; } /* Not a Draw control */ MessageBeep(MB_ICONHAND); - return 0L; + return (LRESULT)0; break; case WM_ENABLE: - if (wParam == 1) { /* WIN32??? */ + if (wParam == (WPARAM)1) { hWnd2 = SetFocus(hWnd); } @@ -3068,53 +3030,72 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) break; } - closeBalloonHelp(); + closeBalloonHelp(5); wHelp(b->helpStr); - return 0L; + return (LRESULT)0; case WM_SETCURSOR: - /*if (any buttons down) - break;*/ - wSetCursor(NULL, curCursor); + // Set normal Arrow cursor, DefWindowProc can override it + SetCursor(LoadCursor(NULL, IDC_ARROW)); if (!mswAllowBalloonHelp) { - return TRUE; + break; } if (IsIconic(mswHWnd)) { - return TRUE; + break; } b = getControlFromCursor(hWnd, NULL); +#ifdef BALLOON_TRACE + fprintf(logFile, "SETCURSOR %s\n", b ? b->helpStr : "NULL"); + fflush(logFile); +#endif if (b == balloonControlButton) { - return TRUE; + //closeBalloonHelp(61); + break; } - if (/*(!IsWindowEnabled(hWnd))*/ GetActiveWindow() != hWnd || - (!b) || b->type == B_DRAW || b->helpStr == NULL) { - closeBalloonHelp(); - return TRUE; + if (GetActiveWindow() != hWnd) { + closeBalloonHelp(62); + break; + } + if (!b) { + closeBalloonHelp(63); + break; + } + if (b->type == B_DRAW) { + closeBalloonHelp(64); + break; + } + if (b->helpStr == NULL) { + closeBalloonHelp(65); + break; } if (b != balloonHelpButton) { - closeBalloonHelp(); + closeBalloonHelp(7); } - +#ifdef BALLOON_TRACE + fprintf(logFile, "SETCURSOR state %d\n", balloonHelpState); + fflush(logFile); +#endif if (balloonHelpState != balloonHelpIdle) { - return TRUE; + break; } balloonHelpTimer = SetTimer(mswHWnd, BALLOONHELP_TIMER, balloonHelpTimeOut, NULL); - if (balloonHelpTimer == (UINT)0) { - return TRUE; + if (balloonHelpTimer == (UINT_PTR)0) { + break; } balloonHelpState = balloonHelpWait; balloonHelpButton = b; - return TRUE; + break; + case WM_SYSCOMMAND: inx = GetWindowWord(hWnd, 0); @@ -3146,7 +3127,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } wWinShow(w, FALSE); - return 0L; + return (LRESULT)0; case WM_CLOSE: inx = GetWindowWord(hWnd, 0); @@ -3168,13 +3149,13 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) (w->winProc(w, wClose_e, NULL, NULL)); } - return 0L; + return (LRESULT)0; } case WM_DESTROY: if (hWnd == mswHWnd) { PostQuitMessage(0L); - return 0L; + return (LRESULT)0; } break; @@ -3192,15 +3173,15 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } } else if (wParam == BALLOONHELP_TIMER) { KillTimer(hWnd, balloonHelpTimer); - balloonHelpTimer = (UINT)0; + balloonHelpTimer = (UINT_PTR)0; startBalloonHelp(); } - return 0L; + return (LRESULT)0; case WM_MENUSELECT: mswAllowBalloonHelp = TRUE; - closeBalloonHelp(); + closeBalloonHelp(8); break; case WM_WINDOWPOSCHANGED: @@ -3221,12 +3202,12 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case 51: count51++; - /*return NULL;*/ + /*return NULL;*/ case WM_PALETTECHANGED: if (wParam == (WPARAM)hWnd) { - return 0L; + return (LRESULT)0; } case WM_QUERYNEWPALETTE: @@ -3240,12 +3221,12 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) InvalidateRect(hWnd, NULL, TRUE); } - return inx; + return (LRESULT)inx; } case WM_ACTIVATE: if (LOWORD(wParam) == WA_INACTIVE) { - closeBalloonHelp(); + closeBalloonHelp(9); } break; @@ -3272,7 +3253,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) inMainWndProc = FALSE; } - return ret; + return (LRESULT)ret; case WM_LBUTTONDOWN: case WM_MOUSEMOVE: @@ -3297,7 +3278,7 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) inMainWndProc = FALSE; } - return ret; + return (LRESULT)ret; default: ; @@ -3379,7 +3360,7 @@ static BOOL InitApplication(HINSTANCE hinstCurrent) wc.cbWndExtra = 4; if (!RegisterClass(&wc)) { - mswFail("RegisterClass(drawClass)"); + mswFail("RegisterClass(drawClass)"); return FALSE; } @@ -3401,11 +3382,11 @@ int PASCAL WinMain(HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, char **argv; int argc; - if (!hinstPrevious) { - if (!InitApplication(hinstCurrent)) { - return FALSE; - } - } + if (!hinstPrevious) { + if (!InitApplication(hinstCurrent)) { + return FALSE; + } + } mswHInst = hinstCurrent; mTitleH = GetSystemMetrics(SM_CYCAPTION) - 1; @@ -3419,6 +3400,7 @@ int PASCAL WinMain(HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, mswLabelFont = GetStockObject(DEFAULT_GUI_FONT); hDc = GetDC(0); mswScale = GetDeviceCaps(hDc, LOGPIXELSX) / 96.0; + hWindowIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(101)); if (mswScale < 1.0) { mswScale = 1.0; @@ -3467,5 +3449,5 @@ int PASCAL WinMain(HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, HtmlHelp(NULL, NULL, HH_UNINITIALIZE, (DWORD)dwCookie); } - return msg.wParam; + return (int)msg.wParam; } |