News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

CB_SETCUEBANNER Message

Started by -Alex-, December 06, 2010, 10:37:06 PM

Previous topic - Next topic

-Alex-

Hi all. I wanted to use the message CB_SETCUEBANNER this way to edit the control of the Combobox:

invoke GetDlgItem,hWnd,1002
invoke SendMessage,eax,CB_SETCUEBANNER,0,addr MyText

However, seems like this message is not recognized, even if i am on Win7.

But Minimum supported client is Windows Vista:
http://msdn.microsoft.com/en-us/library/bb775897(v=VS.85).aspx

Any possibility to activate/bypass it? Maybe some workaround?

Coma

Sure your text (addr MyText) is in the unicode format ?
If not use this to convert it:

invoke  MultiByteToWideChar,CP_ACP,0,ADDR MyText,-1,ADDR BufferWideChar,MAX_PATH
Coma Homepage 20:00-23:00 GMT+2 --- http://ge2001.dyndns.org:44792

-Alex-

Its not the Textproblem (i hope atleast) but the following error at compiling if i try to use the Message:

error A2006: undefined symbol : CB_SETCUEBANNER
error A2114: INVOKE argument type mismatch : argument : 2

Maybe i forgot to use some inc/lib?

This are my current:

include comdlg32.inc
include kernel32.inc
include user32.inc
include windows.inc
includelib comdlg32.lib
includelib kernel32.lib
includelib user32.lib

ramguru

it's missing in windows.inc, so you can define them in your project file or your local hopy of \masm32\include\windows.inc

CB_SETCUEBANNER equ (CBM_FIRST + 3)
CB_GETCUEBANNER equ (CBM_FIRST + 4)

Coma

include \masm32\include\comctl32.inc
includelib \masm32\lib\comctl32.lib

;custom combobox control messages  - missed in windows.inc
CB_SETMINVISIBLE   equ     (CBM_FIRST + 1)
CB_GETMINVISIBLE   equ     (CBM_FIRST + 2)
CB_SETCUEBANNER  equ      (CBM_FIRST + 3)
CB_GETCUEBANNER  equ      (CBM_FIRST + 4)

Example:
MyText db "Test",0 ;==>this is not Unicode
Coma Homepage 20:00-23:00 GMT+2 --- http://ge2001.dyndns.org:44792

donkey

Quote from: Coma on December 07, 2010, 06:44:20 AM
include \masm32\include\comctl32.inc
includelib \masm32\lib\comctl32.lib

You shouldn't need the comctl API to use them, it only requires SendMessage, though I guess you have to call InitCommonControls - Never mind.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

-Alex-

#6
Added:
1)
include comctl32.inc
includelib comctl32.lib
2)
.const
CB_SETMINVISIBLE   equ     (CBM_FIRST + 1)
CB_GETMINVISIBLE   equ     (CBM_FIRST + 2)
CB_SETCUEBANNER  equ      (CBM_FIRST + 3)
CB_GETCUEBANNER  equ      (CBM_FIRST + 4)
3)
invoke GetDlgItem,hWnd,1002
mov Result,eax
invoke MultiByteToWideChar,CP_ACP,0,ADDR MyText,-1,ADDR MyTextBuffer,50h
invoke InitCommonControls
invoke SendMessage,Result,CB_SETCUEBANNER,0,addr MyTextBuffer

Still its empty, but atleast CB_SETCUEBANNER is recognized now and shown as MSG(1703) in Olly.

Edit/Add:
I added the invokes under .if uMsg==WM_INITDIALOG

dedndave

EQUates need not be in a segment/section
they are only constants to the assembler - not the linker

-Alex-

I just added it to be sure, i also have same in windows.inc, however, result is 0, but error code is ERROR_SUCCESS. Thats why i asked u all, as it is maybe just a simple message, which cause so much trouble for me, instead of the project i am currently working on should cause so much trouble..

dedndave

InitCommonControls...
QuoteEnsures that the common control DLL (Comctl32.dll) is loaded, and registers specific common control
classes from the DLL. An application must call this function before creating a common control.
i would put that in the init stage of the program

still looking...

dedndave

the "Return" value should be a handle
if it is 0, that is "INVALID_HANDLE" - not "ERROR_SUCCESS"
in such cases (where 0=error), you have to use GetLastError to retrieve the error code
you can do it with a .IF structure, but i would write the code - lol
something like this....
;program initialization section

invoke InitCommonControls

;

invoke GetDlgItem,hWnd,1002
or eax,eax
jnz @f

invoke GetLastError
jmp Show_Error_Message

@@:
push eax
invoke MultiByteToWideChar,CP_ACP,0,ADDR MyText,-1,ADDR MyTextBuffer,50h
pop eax
invoke SendMessage,eax,CB_SETCUEBANNER,0,addr MyTextBuffer


dedndave

you can use FormatMessage to get the text for the error
;eax = error code
        INVOKE  FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM,NULL,eax,0,offset ErrTextBuf,sizeof ErrTextBuf,NULL

dedndave

i would probably change the order of things a bit...
invoke MultiByteToWideChar,CP_ACP,0,ADDR MyText,-1,ADDR MyTextBuffer,50h
invoke GetDlgItem,hWnd,1002
or eax,eax
jnz @f

invoke GetLastError
invoke FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM,NULL,eax,0,offset ErrTextBuf,sizeof ErrTextBuf,NULL
jmp Show_Error_Message

@@:
invoke SendMessage,eax,CB_SETCUEBANNER,0,addr MyTextBuffer

-Alex-

#13
I attached my sample, which jumps over the GetLastError, but still didnt show the new banner.

dedndave

Bill gives a great example.....

\masm32\examples\bcraven\controls