NO

Author Topic: TTN_GETDISPINFO not send  (Read 16026 times)

czerny

  • Guest
TTN_GETDISPINFO not send
« on: April 29, 2013, 03:17:47 PM »
Hallo,

this is a problem I am searching the error for hours now. It would be nice, if anyone could help!

I have a simple toolbar, composed of the standard bitmap (IDB_STD_LARGE_COLOR) with 15 Buttons and an own bitmap with 5 Buttons (120x24). I use 5 Buttons from the former bitmap, 3 separators and my 5 Buttons.

The toolbar is working ok. There is only one error: the tooltip from the very first button is not working. There is no TTN_GETDISPINFO notification send for this Button. All other Buttons have their tooltips.

A strange observation: If I use one more button as defined (and with luck the program is not crashing) all works ok????
Maybe this could be a hint .

Code: [Select]
#include "windows.h"
#include "res.h"

#define NUMBUTTONS 13

HWND CreateMyToolbar(HWND hparent)
{
int i;

TBBUTTON tbb[NUMBUTTONS] = {0};
        TBADDBITMAP tbab;

HWND hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS, 0, 0, 0, 0,
        hparent, (HMENU)IDC_MAIN_TOOL, GetModuleHandle(NULL), NULL);

  SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);

tbab.hInst = HINST_COMMCTRL;
    tbab.nID = IDB_STD_LARGE_COLOR;
    SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM)&tbab);

tbab.hInst = NULL;
    tbab.nID = (UINT_PTR)LoadImage(GetModuleHandle(NULL),
                                MAKEINTRESOURCE(ID_BMPOWN),
                                IMAGE_BITMAP, 0, 0,
                                LR_DEFAULTSIZE | LR_DEFAULTCOLOR | LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
    int own = SendMessage(hTool, TB_ADDBITMAP, 5, (LPARAM)&tbab);

  i=0;
tbb[i].iBitmap = STD_FILENEW; // 0
    tbb[i].fsState = TBSTATE_ENABLED;
    tbb[i].fsStyle = TBSTYLE_BUTTON;
    tbb[i].idCommand = IDM_FILE_NEW;

i++;
    tbb[i].iBitmap = STD_FILEOPEN; // 1
    tbb[i].fsState = TBSTATE_ENABLED;
    tbb[i].fsStyle = TBSTYLE_BUTTON;
    tbb[i].idCommand = IDM_FILE_OPEN;

i++;
    tbb[i].iBitmap = STD_FILESAVE; // 2
    tbb[i].fsState = 0; //TBSTATE_ENABLED;
    tbb[i].fsStyle = TBSTYLE_BUTTON;
    tbb[i].idCommand = IDM_FILE_SAVE;
   
i++;
tbb[i].fsState = TBSTATE_ENABLED; // 3
    tbb[i].fsStyle = TBSTYLE_SEP;

i++;
    tbb[i].iBitmap = own; // 4
    tbb[i].fsState = 0; //TBSTATE_ENABLED;
    tbb[i].fsStyle = TBSTYLE_BUTTON;
    tbb[i].idCommand = IDM_METHODE_RUN;

i++;
    tbb[i].iBitmap = own + 1; // 5
    tbb[i].fsState = 0; //TBSTATE_ENABLED;
    tbb[i].fsStyle = TBSTYLE_BUTTON;
    tbb[i].idCommand = IDM_METHODE_STOP;

i++;
tbb[i].fsState = TBSTATE_ENABLED; // 6
    tbb[i].fsStyle = TBSTYLE_SEP;

i++;
    tbb[i].iBitmap = own + 2; // 7
    tbb[i].fsState = TBSTATE_ENABLED;
    tbb[i].fsStyle = TBSTYLE_BUTTON;
    tbb[i].idCommand = IDM_DATEN_FILTER;

i++;
    tbb[i].iBitmap = own + 3; // 8
    tbb[i].fsState = TBSTATE_ENABLED;
    tbb[i].fsStyle = TBSTYLE_BUTTON;
    tbb[i].idCommand = IDM_DATEN_FILTERRAD;

i++;
    tbb[i].iBitmap = own + 4; // 9
    tbb[i].fsState = TBSTATE_ENABLED;
    tbb[i].fsStyle = TBSTYLE_BUTTON;
    tbb[i].idCommand = IDM_DATEN_FILTERSEQ;

i++;
tbb[i].fsState = TBSTATE_ENABLED; // 10
    tbb[i].fsStyle = TBSTYLE_SEP;

i++;
    tbb[i].iBitmap = STD_PROPERTIES; // 11
    tbb[i].fsState = TBSTATE_ENABLED;
    tbb[i].fsStyle = TBSTYLE_BUTTON;
    tbb[i].idCommand = IDM_FILE_NEW;

i++;
    tbb[i].iBitmap = STD_HELP; // 12
    tbb[i].fsState = TBSTATE_ENABLED;
    tbb[i].fsStyle = TBSTYLE_BUTTON;
    tbb[i].idCommand = IDM_HELP_LUMINA;
/*
i++;
    tbb[i].iBitmap = STD_HELP; // 13 (an illegal 14. button)
    tbb[i].fsState = TBSTATE_ENABLED;
    tbb[i].fsStyle = TBSTYLE_BUTTON;
    tbb[i].idCommand = IDM_HELP_LUMINA;
*/
    SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
   
return hTool;
}

I must have done a silly mistake.

czerny

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: TTN_GETDISPINFO not send
« Reply #1 on: April 29, 2013, 04:18:26 PM »
Use TTN_GETDISPINFOW.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: TTN_GETDISPINFO not send
« Reply #2 on: April 29, 2013, 06:15:58 PM »
Dublicated id IDM_FILE_NEW ?
May the source be with you

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: TTN_GETDISPINFO not send
« Reply #3 on: April 29, 2013, 08:32:24 PM »
It has nothing to do with your IDs. Tooltips don't send the ANSI notification, that's all.
Try something along these lines... and yes, I know it's assembler and this is a C forum.

  .if uMsg==WM_NOTIFY
      .if [ecx.NMHDR.code]==TTN_GETDISPINFOW
            lea edi, lvh
            invoke GetCursorPos, edi
            invoke ScreenToClient, hList, edi
            movi [edi.LV_HITTESTINFO.flags], LVHT_ONITEM
            invoke SendMessage, hList, LVM_HITTEST, 0, edi

czerny

  • Guest
Re: TTN_GETDISPINFO not send
« Reply #4 on: April 29, 2013, 09:00:40 PM »
Dublicated id IDM_FILE_NEW ?
Timovjl, you are my hero!!!

The most stupid errors take the most time. :'(

Thank you jj2007, for your time.

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: TTN_GETDISPINFO not send
« Reply #5 on: April 30, 2013, 01:20:23 PM »
Thank you jj2007, for your time.

Some time ago I wasted a lot of time chasing a problem with TTN_GETDISPINFO, and it turned out the control sent the Unicode version, but here I was obviously on the wrong track.

czerny

  • Guest
Re: TTN_GETDISPINFO not send
« Reply #6 on: April 30, 2013, 02:40:06 PM »
Some time ago I wasted a lot of time chasing a problem with TTN_GETDISPINFO, and it turned out the control sent the Unicode version, but here I was obviously on the wrong track.
My tooltips are string resources. I have tried to save the resource file as unicode file. There are non-ascii chars in the strings. But all is working with TTN_GETDISPINFO, ansi or unicode. Have you provided the strings directly?
What are your experiences? Are there at all drawbacks to save the rc file in unicode?
« Last Edit: April 30, 2013, 04:00:46 PM by czerny »

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: TTN_GETDISPINFO not send
« Reply #7 on: April 30, 2013, 04:27:06 PM »
Have you provided the strings directly?
What are your experiences? Are there at all drawbacks to save the rc file in unicode?

No drawbacks met so far. Attached is a sample app, the exe shows tooltips in several languages. Open the *.asc in Wordpad and scroll to the end to see how the rc file is structured. Search for SetLanguage and/or ToolTips to see relevant code.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: TTN_GETDISPINFO not send
« Reply #8 on: April 30, 2013, 06:56:57 PM »
Another example to use multilanguage menu/tooltips from resource with this function:
Code: [Select]
void SetLang(HWND hwnd, LANGID lid)
{
typedef LANGID (WINAPI *fnSetThreadUILanguage) (LANGID wReserved);
HMENU hMenu;
if ((GetVersion() & 0x00FF) > 5) // Vista =>
{
fnSetThreadUILanguage fnPtr = (fnSetThreadUILanguage)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetThreadUILanguage");
if (fnPtr)
(*fnPtr) (lid);
} else
SetThreadLocale(MAKELCID(lid, SORT_DEFAULT));
hMenu = GetMenu(hwnd);
SetMenu(hwnd, NULL);
DestroyMenu(hMenu);
hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(2001));
SetMenu(hwnd, hMenu);
}
EDIT: Fix for WinXP and Win8 ???
« Last Edit: May 02, 2013, 04:10:21 PM by timovjl »
May the source be with you

czerny

  • Guest
Re: TTN_GETDISPINFO not send
« Reply #9 on: April 30, 2013, 08:18:24 PM »
No drawbacks met so far. Attached is a sample app, the exe shows tooltips in several languages. Open the *.asc in Wordpad and scroll to the end to see how the rc file is structured. Search for SetLanguage and/or ToolTips to see relevant code.
The tooltips are working in english, russian and arabic, not in chinese (but thats a missing font). The label and editbox texts are only working in english.

czerny

  • Guest
Re: TTN_GETDISPINFO not send
« Reply #10 on: April 30, 2013, 08:29:09 PM »
Another example to use multilanguage menu/tooltips from resource with this function:
Are there any non ascii characters in suomi?

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: TTN_GETDISPINFO not send
« Reply #11 on: April 30, 2013, 10:58:50 PM »
Another example...

Seems not to work, I see English only, and "Finnish" gets never checked. Win XP SP3...

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: TTN_GETDISPINFO not send
« Reply #12 on: May 01, 2013, 06:01:13 AM »
The label and editbox texts are only working in english.
Clicking "Pushme" or "Sayhi" shows something in the editbox. The rest is not implemented.

czerny

  • Guest
Re: TTN_GETDISPINFO not send
« Reply #13 on: May 01, 2013, 10:13:08 PM »
Another example...
Seems not to work, I see English only, and "Finnish" gets never checked. Win XP SP3...
No problem with good old win2k! ;D

czerny

  • Guest
Re: TTN_GETDISPINFO not send
« Reply #14 on: May 01, 2013, 10:21:18 PM »
The label and editbox texts are only working in english.
Clicking "Pushme" or "Sayhi" shows something in the editbox. The rest is not implemented.
Yes, but what it shows are black lines in all languages but english. See picture for russian.

I have installed simsun.ttf and wordpad shows now the chinese chars while your application shows still strings of undef chars.
« Last Edit: May 01, 2013, 10:43:20 PM by czerny »