Author Topic: Enable tooltips for the Select game dialog...  (Read 10913 times)

Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Enable tooltips for the Select game dialog...
« on: October 07, 2010, 02:17:20 AM »
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:
Code: [Select]
    IDS_ROMS_SELECT_DIR        "Select Directory:"
Add ths after:
Code: [Select]
    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:
Code: [Select]
#define IDS_ROMS_SELECT_DIR        (IDS_STRING +  80)
add this after:
Code: [Select]
#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:
Code: [Select]
extern bool bIsWindowsXPorGreater;
BOOL DetectWindowsVersion();

In the same file, look for // sel.cpp section, and add this prototype after:
Code: [Select]
HWND CreateToolTip(int nToolID, HWND hDlg, PTSTR pszText);
Now, open misc_win32.cpp and add this after th "burner.h" include directive:
Code: [Select]
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:
Code: [Select]
//   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:
Code: [Select]
        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:
Code: [Select]
    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:
Code: [Select]
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 :D

See ya!!! :D

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?
« Last Edit: October 07, 2010, 02:33:16 AM by FerchogtX »

Good and evil co-exist because of the balance, lies are not part of it...

FB Alpha Plus! site infos updated, see the latest info clicking on my profile link...

Offline CaptainCPS

  • FBNeo Dev
  • ******
  • Posts: 1513
  • Karma: +127/-0
  • FB Alpha Team
    • CaptainCPS's Home
Re: Enable tooltips for the Select game dialog...
« Reply #1 on: October 07, 2010, 04:04:05 AM »
Nice stuff bro! ^^ , Im gonna take a look at what might be the problem with the code and post back anything I find out =).

Thanks for sharing the code  ;p

SeeYaa!
 :biggrin:

Offline CaptainCPS

  • FBNeo Dev
  • ******
  • Posts: 1513
  • Karma: +127/-0
  • FB Alpha Team
    • CaptainCPS's Home
Re: Enable tooltips for the Select game dialog...
« Reply #2 on: October 07, 2010, 06:10:15 AM »
I found out what was wrong FerchogtX =). I took a time to rewrite the module and made a simpler one. The main problem was that tool tips are not associated at Paint message (WM_PAINT). They are associated just once, and then the application will always know when and how to draw them eventually, there were other few things that were not done as well.

Replace the old "CreateToolTip()" with this one CreateToolTipForRect()...

Code: [Select]
void CreateToolTipForRect(HWND hwndParent, PTSTR pszText)
{
// Check if we are running Windows XP/Vista/7
    bIsWindowsXPorGreater = DetectWindowsVersion();
   
HWND hwndTT = NULL;

// Create a tooltip.
if(bIsWindowsXPorGreater) {
hwndTT = CreateWindowEx( WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP | TTS_BALLOON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndParent, NULL, hAppInst, NULL);
} else {
hwndTT = CreateWindowEx( WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndParent, NULL, hAppInst, NULL);
}

    SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);

    // Set up "tool" information.
    TOOLINFO ti = { 0 };
    ti.cbSize = sizeof(TOOLINFO);
    ti.uFlags = TTF_SUBCLASS;
    ti.hwnd = hwndParent;
    ti.hinst = hAppInst;
    ti.lpszText = pszText;
    GetClientRect (hwndParent, &ti.rect); // rect of the button, window, etc...assosiated with the tooltip

    // Associate the tooltip with the "tool" window.
    SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
}

Add these DialogProc after CheckInfoButtons();...

Code: [Select]
CreateToolTipForRect(GetDlgItem(hSelDlg, IDC_VIEWGINFO_B) ,FBALoadStringEx(hAppInst, IDS_VIEW_GAME_INFO, true));
CreateToolTipForRect(GetDlgItem(hSelDlg, IDC_ADDFAV_B) ,FBALoadStringEx(hAppInst, IDS_ADD_FAVORITE, true));
CreateToolTipForRect(GetDlgItem(hSelDlg, IDC_DELFAV_B) ,FBALoadStringEx(hAppInst, IDS_DEL_FAVORITE, true));
CreateToolTipForRect(GetDlgItem(hSelDlg, IDC_JUKE_B) ,FBALoadStringEx(hAppInst, IDS_JUKEBOX, true));
CreateToolTipForRect(GetDlgItem(hSelDlg, IDC_MAWS_B) ,FBALoadStringEx(hAppInst, IDS_MAWS, true));
CreateToolTipForRect(GetDlgItem(hSelDlg, IDC_CAESAR_B) ,FBALoadStringEx(hAppInst, IDS_CAESAR, true));
CreateToolTipForRect(GetDlgItem(hSelDlg, IDC_PROGETTOEMMA_B) ,FBALoadStringEx(hAppInst, IDS_PROGETTOEMMA, true));

And remove the WM_PAINT code completely just in case.

Everything is working fine after this =).

Hope you like this bro. ^^

SeeYaa!
 :biggrin:
« Last Edit: October 07, 2010, 06:11:57 AM by CaptainCPS-X »

Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Re: Enable tooltips for the Select game dialog...
« Reply #3 on: October 07, 2010, 11:32:38 PM »
Works like a charm dude!!! hanks for it (I know you could do it XD)
BTW... this structure definition:
Code: [Select]
TOOLINFO ti      = { 0 };Gets some cmpile warnings about the initializer... but this:
Code: [Select]
TOOLINFO ti;compiles with no warnings, no bugs, no problems.

Thanks for the fix man!!
Just for the record... where did you learn about tooltip implementation on WinAPI? I've looked around on several sites, but that faulty code of mine was taken from MSDN... the best i could get :( if you have the full tutorial or course, It will be really helpfull for me ;P

See ya!!! :D

Good and evil co-exist because of the balance, lies are not part of it...

FB Alpha Plus! site infos updated, see the latest info clicking on my profile link...

Offline CaptainCPS

  • FBNeo Dev
  • ******
  • Posts: 1513
  • Karma: +127/-0
  • FB Alpha Team
    • CaptainCPS's Home
Re: Enable tooltips for the Select game dialog...
« Reply #4 on: October 08, 2010, 02:50:20 AM »
Works like a charm dude!!! hanks for it (I know you could do it XD)
BTW... this structure definition:
Code: [Select]
TOOLINFO ti      = { 0 };Gets some cmpile warnings about the initializer... but this:
Code: [Select]
TOOLINFO ti;compiles with no warnings, no bugs, no problems.

Thanks for the fix man!!
Just for the record... where did you learn about tooltip implementation on WinAPI? I've looked around on several sites, but that faulty code of mine was taken from MSDN... the best i could get :( if you have the full tutorial or course, It will be really helpfull for me ;P

See ya!!! :D

Yeah initializing a structure to Zero gives compiler warnings if made that way xD. About where did I learn about Tooltips for WinAPI, well I honestly didn't have any knowledge about it because I never thought about implementing Tooltips, but when you came with the idea and the code, I went to get documentation on different sites around the net (including MSDN) and eventually I was able to understand how they work  :smilie:.

I find almost any WinAPI topic easy to learn as far as is not a custom class or something. Working on so many features for the FBA UI made me grow in understanding how to code using WinAPI libraries.

If you want to know more about something in specific for WinAPI let me know man I will gladly help on any idea you have or any doubt. It is always a pleasure to collaborate in any way I can, and in the process I learn as well ^^.

Saludos compa!, tal vez creare un foro para nosotros compartir codigo y tal vez trabajar en una version semi-oficial del FBA con los drivers mas actuales de MAME ya que aunque IQ y yo somos del equipo oficial de FBA, siempre esperamos a que Barry publique cada version oficial en su pagina. Y como el esta desconectado de hace un tiempo por cuestiones personales pues he estado considerando sacar una version semi-oficial pronto con algunos arreglos =). Si te interesa luego te aviso con mas detalles por MP, ya que tengo que consultar a IQ tambien a ver que el piensa.

 :biggrin:

Offline KaaMoS

  • Member
  • ***
  • Posts: 136
  • Karma: +1/-0
Re: Enable tooltips for the Select game dialog...
« Reply #5 on: October 08, 2010, 05:18:24 PM »
Hey... cuidado!
Que aquí hay gente con problemas del corazón!!!

"Un FBA" hecho por IQ_132, CaptainCPS-X y FerchoGTX sería increíble!!
Ustedes tres han hecho grandiosos aportes para el FBA original... ahora, con la oportunidad de expandir su imaginación con algo propio... va a resultar algo como de la NASAi!!!

Ánimooo!  :biggrin:
« Last Edit: October 08, 2010, 05:19:26 PM by KaaMoS »

Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Re: Enable tooltips for the Select game dialog...
« Reply #6 on: October 08, 2010, 07:36:44 PM »
Yeah initializing a structure to Zero gives compiler warnings if made that way xD. About where did I learn about Tooltips for WinAPI, well I honestly didn't have any knowledge about it because I never thought about implementing Tooltips, but when you came with the idea and the code, I went to get documentation on different sites around the net (including MSDN) and eventually I was able to understand how they work  :smilie:.

I find almost any WinAPI topic easy to learn as far as is not a custom class or something. Working on so many features for the FBA UI made me grow in understanding how to code using WinAPI libraries.

If you want to know more about something in specific for WinAPI let me know man I will gladly help on any idea you have or any doubt. It is always a pleasure to collaborate in any way I can, and in the process I learn as well ^^.

Saludos compa!, tal vez creare un foro para nosotros compartir codigo y tal vez trabajar en una version semi-oficial del FBA con los drivers mas actuales de MAME ya que aunque IQ y yo somos del equipo oficial de FBA, siempre esperamos a que Barry publique cada version oficial en su pagina. Y como el esta desconectado de hace un tiempo por cuestiones personales pues he estado considerando sacar una version semi-oficial pronto con algunos arreglos =). Si te interesa luego te aviso con mas detalles por MP, ya que tengo que consultar a IQ tambien a ver que el piensa.

 :biggrin:

Pues... no seria mala idea... igual y juntos podemos revivir el FBA Plus!, quien sabe... es solo una idea, igualmente otro build no es mala idea... igual y podemos rescatar ciertos sets que el mame no tiene tan bien como ellos piensan (como el kf2k2spr... IQ hace bastante me confirmo un layout que aun conservo y que el mismo dumper le dio...)... solo sera cosa de que el te diga que onda, en una de esas pues me regreso con ustedes... la verdad es que agarre lo del mugen por que no tenia tiempo para la emulacion, ahora ando mas tranquilo con otro trabajo que me da el tiempo para volver... y no ha sido tan grato el tiempo que le inverti a ese engine (hay mucho escuincle de 10 años que cree que por saber jugar bien la mvc2, pueden juzgar como rayos crear un personaje de mugen... y lo peor es como te lo dicen... pero eso es otra historia).

Tengo que decirlo, cunado vi los foros de neosource me regreso la nostalgia, y la verdad es que aqui pase mis mejores tiempos en cuanto a la emulacion, seria muy bueno volver con algo :D Haber que te dice el buen IQ :D

Hey... cuidado!
Que aquí hay gente con problemas del corazón!!!

"Un FBA" hecho por IQ_132, CaptainCPS-X y FerchoGTX sería increíble!!
Ustedes tres han hecho grandiosos aportes para el FBA original... ahora, con la oportunidad de expandir su imaginación con algo propio... va a resultar algo como de la NASAi!!!

Ánimooo!  :biggrin:
Pueda que si, uno nunca sabe XD

Un saludote :D

P.D. Sorry for posting in spanish, if you need translation (other forum members) feel free to ask ;)

Good and evil co-exist because of the balance, lies are not part of it...

FB Alpha Plus! site infos updated, see the latest info clicking on my profile link...

Offline CaptainCPS

  • FBNeo Dev
  • ******
  • Posts: 1513
  • Karma: +127/-0
  • FB Alpha Team
    • CaptainCPS's Home
Re: Enable tooltips for the Select game dialog...
« Reply #7 on: October 08, 2010, 11:56:32 PM »
[Sorry for the following spanish message, I will translate later if possible, im lazy now xD lol]

Pues mira FerchogtX te tengo una mejor propuesta ya que Barry (Treble Winner) esta todavia por ahi, en nuestro lugar secreto hemos consultado sobre una idea que me surgio de hacer una version RC (Release Candidate) y Barry nos ha mencionado no sera necesario ya que dentro de unas semanas tendra sus ultimas actualizaciones y sincronizacion con las ultimas mejoras del MAME y pues IQ tiene muchisimos drivers esperando a ser agregados en cuanto Barry postee su ultimo codigo fuente en nuestro lugar secreto xD.

Yo por mi parte he decidido mejor esperar por Barry y seguir todos trabajando en la version oficial.

Hemos consultado y decidimos que seria una buena idea que participaras directamente con el projecto oficial. Si te interesa tendras acceso a nuestro foro de desarrollo privado y testear muchisimas cosas que tenemos por ahi xD. Sera un placer para IQ, Barry y para mi que te unieras al desarrolllo de la version oficial. Asi no tendrias que estar trabajando con dos codigos fuentes a la hora de actualizar :p.

Espero tu respuesta compa!. ^^

(De todos modos cambiare tu estatus xD, se supone que puedas accesar a nuestro foro privado de desarrollo)

Saludos.

Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Re: Enable tooltips for the Select game dialog...
« Reply #8 on: October 09, 2010, 12:15:24 AM »
Pues encantado!!! he dejado esto un tiempo, pero cualquier cosa en la que pueda ser de ayuda (a lo mejor cosillas esteticas, o arreglar drivers... alguna vez estuv a punto de pasar juegos de konami a FBa... lo bueno que IQ lo logro con mejores resultados XD)

Saludos :D

Good and evil co-exist because of the balance, lies are not part of it...

FB Alpha Plus! site infos updated, see the latest info clicking on my profile link...

Offline doomking

  • Jr. Member
  • **
  • Posts: 69
  • Karma: +21/-0
Re: Enable tooltips for the Select game dialog...
« Reply #9 on: October 09, 2010, 06:34:30 AM »
Works like a charm dude!!! hanks for it (I know you could do it XD)
BTW... this structure definition:
Code: [Select]
TOOLINFO ti      = { 0 };Gets some cmpile warnings about the initializer... but this:
Code: [Select]
TOOLINFO ti;compiles with no warnings, no bugs, no problems.

Code: [Select]
TOOLINFO ti      = { 0 };replace with:
Code: [Select]
TOOLINFO ti      = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

Offline kenshiro

  • Expert
  • *****
  • Posts: 145
  • Karma: +21/-0
Re: Enable tooltips for the Select game dialog...
« Reply #10 on: October 09, 2010, 04:46:54 PM »
Code: [Select]
TOOLINFO ti      = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

You can simply do:

Code: [Select]
TOOLINFO ti      = { 0, }
Edit: Apparently my compiler doesn't care about initializing a struct with 0. i use gcc-4.4.3-r2 under Gentoo  :p

« Last Edit: October 09, 2010, 04:58:44 PM by kenshiro »

Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Re: Enable tooltips for the Select game dialog...
« Reply #11 on: October 10, 2010, 01:15:21 AM »
Good one... it seems that gcc 3.4.5 has issues with this anyway... but initializing everithng solves the problem...

See ya!!! :D

Good and evil co-exist because of the balance, lies are not part of it...

FB Alpha Plus! site infos updated, see the latest info clicking on my profile link...

Offline doomking

  • Jr. Member
  • **
  • Posts: 69
  • Karma: +21/-0
Re: Enable tooltips for the Select game dialog...
« Reply #12 on: October 10, 2010, 06:09:09 AM »
@kenshiro

i use GCC 4.5.1, but i too like code cleanup...
thx...

Offline CaptainCPS

  • FBNeo Dev
  • ******
  • Posts: 1513
  • Karma: +127/-0
  • FB Alpha Team
    • CaptainCPS's Home
Re: Enable tooltips for the Select game dialog...
« Reply #13 on: October 10, 2010, 07:35:40 AM »
Just for the record, this would be the most appropriate way to initiate the structure  :smilie:.

Code: [Select]
TOOLINFO ti;
memset(&ti, 0, sizeof(TOOLINFO));

I'm not saying the other code doesn't work but, imagine this, Commctrl.h is updated in the future, and includes new structure members, now when we compile we will definitely encounter problems if we initiated every structure in our application using a 'constant' style. If we use 'memset' with 'sizeof(TOOLINFO)' then we will not have any problems, even if there are more structure members added in the future.

SeeYaa!
 :biggrin:


Offline kenshiro

  • Expert
  • *****
  • Posts: 145
  • Karma: +21/-0
Re: Enable tooltips for the Select game dialog...
« Reply #14 on: October 10, 2010, 11:36:06 AM »
Agreed :)

I usually use memset to initialize a struct, this is safe, short and efficient. I just wasn't know that the C compiler would accept something like
Code: [Select]
OOLINFO ti      = { 0, }
It really surprised me lol  :p