Well... while trying to remember old time doing nasty stuff on the GUI, I saw that the info buttons n the Sel game dialog have no tooltips... some people that don't know what they do, may find that a bit confusing, so I did a lil' thing to enable tooltips for the dialog. I also include code for detecting if we are running on Windows XP or greater, this is important for the tooltip code itself, but can be used for many other things.
First, open burner\win32\string.rc and find:
IDS_ROMS_SELECT_DIR "Select Directory:"
Add ths after:
IDS_VIEW_GAME_INFO "View game info..."
IDS_ADD_FAVORITE "Add to favorites"
IDS_DEL_FAVORITE "Delete from favorites"
IDS_JUKEBOX "Load jukebox module"
IDS_CAESAR "View game info in Caesar"
IDS_MAWS "View game info in MAWS"
IDS_PROGETTOEMMA "View game info in Progetto EMMA"
then, open resource_string.h and find:
#define IDS_ROMS_SELECT_DIR (IDS_STRING + 80)
add this after:
#define IDS_VIEW_GAME_INFO (IDS_STRING + 81)
#define IDS_ADD_FAVORITE (IDS_STRING + 82)
#define IDS_DEL_FAVORITE (IDS_STRING + 83)
#define IDS_JUKEBOX (IDS_STRING + 84)
#define IDS_CAESAR (IDS_STRING + 85)
#define IDS_MAWS (IDS_STRING + 86)
#define IDS_PROGETTOEMMA (IDS_STRING + 87)
open burner_win32.h and find // misc_win32.cpp section, add this after:
extern bool bIsWindowsXPorGreater;
BOOL DetectWindowsVersion();
In the same file, look for // sel.cpp section, and add this prototype after:
HWND CreateToolTip(int nToolID, HWND hDlg, PTSTR pszText);
Now, open misc_win32.cpp and add this after th "burner.h" include directive:
bool bIsWindowsXPorGreater = FALSE;
// Detect if we are using Windows XP/Vista/7
BOOL DetectWindowsVersion()
{
OSVERSIONINFO osvi;
BOOL bIsWindowsXPorLater;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
// osvi.dwMajorVersion returns the windows version: 5 = XP 6 = Vista/7
// osvi.dwMinorVersion returns the minor version, XP and 7 = 1, Vista = 0
bIsWindowsXPorLater = ((osvi.dwMajorVersion > 5) || ( (osvi.dwMajorVersion == 5) && (osvi.dwMinorVersion >= 1)));
return bIsWindowsXPorLater;
}
Now the best part, open sel.cpp and add this before CheckInfoButtons() function:
// Creates a tooltip for an item in a dialog box.
HWND CreateToolTip(int nToolID, HWND hDlg, PTSTR pszText)
{
HWND HwndTTip = NULL;
if (!nToolID || !hDlg || !pszText) {
return FALSE;
}
// Get the window of the tool.
HWND HwndItem = GetDlgItem(hDlg, nToolID);
// Check if we are running Windows XP/Vista/7
bIsWindowsXPorGreater = DetectWindowsVersion();
// Create the tooltip. hAppInst is the global instance handle.
if (bIsWindowsXPorGreater) {
// In this case, this type will be shown only on XP/Vista or 7 OSes
HwndTTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP |TTS_ALWAYSTIP | TTS_BALLOON, 0, 0, 0, 0, hDlg, NULL, hAppInst, NULL);
} else {
// This one is for older versions (Windows 2000, ME, 98, NT...)
HwndTTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP |TTS_ALWAYSTIP, 0, 0, 0, 0, hDlg, NULL, hAppInst, NULL);
}
if (!HwndItem || !HwndTTip) {
return NULL;
}
// Associate the tooltip with the tool.
TOOLINFO ToolInfo;
ToolInfo.cbSize = sizeof(ToolInfo);
ToolInfo.hwnd = hDlg;
ToolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
ToolInfo.uId = (UINT_PTR)HwndItem;
ToolInfo.lpszText = pszText;
SendMessage(HwndTTip, TTM_ADDTOOL, 0, (LPARAM)&ToolInfo);
return HwndTTip;
}
the code explains itself... now, implementation, look for the "DialogProc" Diaog procedure function and look for this:
ShowWindow(hFavListView, SW_HIDE); // Hide Favorites Gamelist
ShowWindow(GetDlgItem(hSelDlg, IDC_CHECKAVAILABLEONLY), SW_HIDE);
ShowWindow(GetDlgItem(hSelDlg, IDC_CHECKAUTOEXPAND), SW_HIDE);
ShowWindow(GetDlgItem(hSelDlg, IDC_SEL_SHORTNAME), SW_HIDE);
ShowWindow(GetDlgItem(hSelDlg, IDC_SEL_ASCIIONLY), SW_HIDE);
ShowWindow(GetDlgItem(hSelDlg, IDC_OPT_STATIC), SW_HIDE);
// ------------------------------------------------------------
// Loading / Unloading of driver icons is done in main.cpp now
/* LoadDrvIcons(); */
CheckInfoButtons();
return TRUE;
}
add this after:
if (Msg == WM_PAINT) {
CreateToolTip(IDC_VIEWGINFO_B, hSelDlg, FBALoadStringEx(hAppInst, IDS_VIEW_GAME_INFO, true));
CreateToolTip(IDC_ADDFAV_B, hSelDlg, FBALoadStringEx(hAppInst, IDS_ADD_FAVORITE, true));
CreateToolTip(IDC_DELFAV_B, hSelDlg, FBALoadStringEx(hAppInst, IDS_DEL_FAVORITE, true));
CreateToolTip(IDC_JUKE_B, hSelDlg, FBALoadStringEx(hAppInst, IDS_JUKEBOX, true));
CreateToolTip(IDC_MAWS_B, hSelDlg, FBALoadStringEx(hAppInst, IDS_MAWS, true));
CreateToolTip(IDC_CAESAR_B, hSelDlg, FBALoadStringEx(hAppInst, IDS_CAESAR, true));
CreateToolTip(IDC_PROGETTOEMMA_B, hSelDlg, FBALoadStringEx(hAppInst, IDS_PROGETTOEMMA, true));
}
That's all, now you have tooltips enabled for the info buttns... this enable balloon type tooltips for XP and greater, 2000 and older will get the normal type (I guess that no one this days still use win2000 XD) if you need the Windows version check function on other stuff, you just need to call the function like this:
bIsWindowsXPorGreater = DetectWindowsVersion();
and use the boolean var the way you need to...
Known problems:Shame of me... this has only one problem, whenever you set your mouse over the button, the tooltip displays, if you leave it that way and wait for tooltip timeout, it won't show again until you switch tabs ot exit game select dialog... I'm still trying to see what is the problem (maybe I need to find which message type is processed always, so the tooltips are generated over and over again... but i'm not sure, I'm still understanding and getting all possible messages for dialogs process) If anyone gets the spot, feel free to post...
As always, this code is free, use it however you like
See ya!!!
P.D.: Attached a lil' screenshot... tested on XP (my current compile enviornment on a virtual machne) and windows 7 (my native OS)
P.D.2: Doing some extra tests... it seems that only XP exhibits the problem described above... which common controls version are we using in ths version of FBA?