admin管理员组文章数量:1193740
I asked a question a few days ago and someone suggested setting a cuebanner rather showing a messagebox using WM_MOUSEHOVER. So I wanted to try setting a cuebanner as suggested.
I wrote a demo program and the code assembles okay but I don't see any cuebanner displayed when I run the program. I must admit I'm not sure what a cuebanner should look like. So, I am hoping someone can clarify what a cuebanner does (what should I expect to see) and help me understand what I did wrong in the demo program, which I included.
;*************** INCLUDE MASM32 RUNTIME LIBRARY & MASM32 DEBUG MACROS *************************
include \masm32\include\masm32rt.inc ; MASM32 RUNTIME LIBRARY for MASM32. Includes windows.inc
; (which includes winextra.inc), as well as Windows API
; include & library files (e.g., user32.inc, user32.lib,
; kernel32.inc, etc.), dialogs.inc, & macros.asm
include \masm32\include\debug.inc ; MASM32 DEBUG MACROS for VKDEBUG. Defines 6 "helper" macros
; used to display data in various formats (e.g., HEX, DECIMAL,
; ASCII), 4 constants, and 17 macros for debugging purposes.
includelib \masm32\lib\debug.lib ; MASM32 DEBUG LIBRARY for VKDEBUG. Defines 7 external
; procedures & 9 external variables referenced by
; debug.inc for VKDEBUG
;****************************** DEFINE PROCEDURE PROTOTYPES ***********************************
DlgProc proto hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.const
MAXSIZE equ 260 ; Maximum size of a file name
MEMSIZE equ 65535 ; Maximum size of a memory buffer
; Define Resource Control Identities (must match identity assigned in resource control)
; ---------------- DEFINE EDIT CONTROL IDENTITIES --------------
; ---------------- DEFINE EDIT CONTROL LABEL IDENTITIES --------------
; -------------DEFINE BUTTON IDENTITIES--------------
BTN_Enter equ 1051 ; Enter Button
BTN_Exit equ 1052 ; Exit Button
; ----------DEFINE MENU IDENTITIES------------
MyMenu equ 2000 ; Define Menu Identity
IDC_Edit1001 equ 1001
IDC_STATIC1002 equ 1002
IDM_Exit equ 1003
IDM_Help equ 1004
IDM_About equ 1005
; ---------------- END OF RESOURCE CONTROL DEFINITIONS --------------------------
;******************* DEFINE PROGRAM DATA with INITIALIZED VALUES *******************
.data
;--------------------------- DEFINE ZERO-TERMINATED STRINGS ----------------------------------------
DlgName db "MyDialog",0
MenuName db "MyMenu",0
MsgBoxTitle db "My Test Dialog Box ",0
About_String1 db "CueBanner Demo1/21/2025",0
Help_String db "Help (UNDER CONSTRUCTION).",0
Enter_String db "You Pressed Enter", 0
IDC_Edit1001CueBanner db "This is the CueBanner for IDC_Edit1001",0
;********************* DEFINE PROGRAM DATA with UNINITIALIZED VALUES *********************
.data?
; HANDLES
hInstance HINSTANCE ?
hDlg HWND ?
hCtrl HWND ?
CommandLine LPSTR ?
hIDC_Edit1001 HWND ?
;-----------------------------------------------------------------------------------------------------------------------------------------------------
BIGbuffer db 0FFFFh dup(?) ; Memory variable used to temporarily store data for further processing
;-------------------------------------------------------------------------------------------------------------------------------------------------------
dwPTR TYPEDEF PTR DWORD ; Use of "dwPTR" DATATYPE is KEY to defining PTR as a "POINTER"
lpIDC_Edit1001CueBanner dwPTR ?
;**************************************************************************************************************************************************
.code
;-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke DialogBoxParam, hInstance, addr DlgName,NULL, addr DlgProc, NULL ; Create Dialog Box
mov hDlg, eax ; Save the handle to the Dialog Box
INVOKE ExitProcess, eax
;******************************************************************************************************************************************************
DlgProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
;================================================================================
;============================= BEGIN MESSAGE LOOP ==============================
; Window Message -- Initialize Dialog Box
;--------------------------------------------------------------------------------------------------------------------------------------------
.IF uMsg==WM_INITDIALOG
invoke GetDlgItem,hWnd,IDC_Edit1001
mov hIDC_Edit1001,eax
LEA eax,IDC_Edit1001CueBanner
mov lpIDC_Edit1001CueBanner, eax
invoke SendMessage,hIDC_Edit1001,EM_SETCUEBANNER,lpIDC_Edit1001CueBanner,TRUE
;--------------------------------------------------------------------------------------------------------------------------------------------
.ELSEIF uMsg==WM_NOTIFY
push esi
mov esi,lParam
assume esi:ptr NMHDR
;------------------------------------------
.IF [esi].code==EN_MSGFILTER
assume esi:ptr MSGFILTER
;------------------------------------------
.IF [esi].msg==WM_LBUTTONDBLCLK
invoke GetFocus
mov hCtrl, eax
invoke GetDlgCtrlID,hCtrl
;=========================================
.ENDIF
;----------------------------------------------------------------------------------------------------------------
.ENDIF
;
; Window Message - Close Dialog Box (EXIT Program)
.ELSEIF uMsg==WM_CLOSE
invoke SendMessage,hWnd,WM_COMMAND,IDM_Exit,0
;--------------------------------------------------------------------------------------------------------------------------------------------
; Window COMMAND Messages
.ELSEIF uMsg==WM_COMMAND
mov eax,wParam
;========== Determine SOURCE of WM_COMMAND (MENU or BUTTON) ======================
.IF lParam==0
;=======================================================================
; SOURCE is MENU -- Determine Menu Option Selected
; BEGIN PROGRAM FLOW CONTROL VIA MENU SELECTIONS
;=======================================================================
MenuSelections:
;=======================================================================
.IF ax==IDM_Help
invoke MessageBox, NULL,ADDR Help_String, ADDR MsgBoxTitle,MB_OK
;-------------------------------------------------------------------------------------------------------------------------
.ELSEIF ax==IDM_About
invoke MessageBox,NULL,ADDR About_String1, ADDR MsgBoxTitle, MB_OK
;-------------------------------------------------------------------------------------------------------------------------
.ELSEIF ax==IDM_Exit
invoke EndDialog, hWnd,NULL
.ENDIF
;=======================================================================
.ELSE ; SOURCE is BUTTON -- Determine BUTTON Option Selected
;=======================================================================
mov edx,wParam
shr edx,16
.IF dx==BN_CLICKED
.IF ax==BTN_Enter
invoke MessageBox, NULL,ADDR Enter_String, ADDR MsgBoxTitle,MB_OK
.ELSEIF ax==BTN_Exit
invoke SendMessage,hWnd,WM_COMMAND,IDM_Exit,0
.ENDIF
.ENDIF
.ENDIF
.ELSE
mov eax,FALSE
RET
.ENDIF
mov eax,TRUE
RET
DlgProc ENDP
end start
;This Resource Script was generated by WinAsm Studio.
#include "resource.h"
#include "richedit.h"
#include "commctrl.h"
#define IDC_Edit1001 1001
#define IDC_STATIC1002 1002
#define IDM_Exit 1003
#define IDM_Help 1004
#define IDM_About 1005
#define BTN_Enter 1051
#define BTN_Exit 1052
#define MyMenu 2000
MyMenu MENUEX DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit",IDM_Exit
END
POPUP "&Help"
BEGIN
MENUITEM "&Help",IDM_Help
MENUITEM "&About",IDM_About
END
END
MYDIALOG DIALOGEX 10,10,400,200
CAPTION "CueBanner Demo Dialog Box"
FONT 8,"MS Shell Dlg"
MENU MyMenu
STYLE 0x90fb08d8
EXSTYLE 0x00000000
BEGIN
CONTROL "ENTER",BTN_Enter,"Button",NOT 0x00010000 | 0x10400000,63,105,50,20,0x00000000
CONTROL "EXIT",BTN_Exit,"Button",NOT 0x00010000 | 0x10400000,127,105,50,20,0x00000000
CONTROL "",IDC_Edit1001,"Edit",0x50810080,17,22,167,55,0x00000200
CONTROL "Plain Edit Control for CueBanner Demo",IDC_STATIC1002,"Static",0x50000000,20,83,164,10,0x00000000
END
I asked a question a few days ago and someone suggested setting a cuebanner rather showing a messagebox using WM_MOUSEHOVER. So I wanted to try setting a cuebanner as suggested.
I wrote a demo program and the code assembles okay but I don't see any cuebanner displayed when I run the program. I must admit I'm not sure what a cuebanner should look like. So, I am hoping someone can clarify what a cuebanner does (what should I expect to see) and help me understand what I did wrong in the demo program, which I included.
;*************** INCLUDE MASM32 RUNTIME LIBRARY & MASM32 DEBUG MACROS *************************
include \masm32\include\masm32rt.inc ; MASM32 RUNTIME LIBRARY for MASM32. Includes windows.inc
; (which includes winextra.inc), as well as Windows API
; include & library files (e.g., user32.inc, user32.lib,
; kernel32.inc, etc.), dialogs.inc, & macros.asm
include \masm32\include\debug.inc ; MASM32 DEBUG MACROS for VKDEBUG. Defines 6 "helper" macros
; used to display data in various formats (e.g., HEX, DECIMAL,
; ASCII), 4 constants, and 17 macros for debugging purposes.
includelib \masm32\lib\debug.lib ; MASM32 DEBUG LIBRARY for VKDEBUG. Defines 7 external
; procedures & 9 external variables referenced by
; debug.inc for VKDEBUG
;****************************** DEFINE PROCEDURE PROTOTYPES ***********************************
DlgProc proto hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.const
MAXSIZE equ 260 ; Maximum size of a file name
MEMSIZE equ 65535 ; Maximum size of a memory buffer
; Define Resource Control Identities (must match identity assigned in resource control)
; ---------------- DEFINE EDIT CONTROL IDENTITIES --------------
; ---------------- DEFINE EDIT CONTROL LABEL IDENTITIES --------------
; -------------DEFINE BUTTON IDENTITIES--------------
BTN_Enter equ 1051 ; Enter Button
BTN_Exit equ 1052 ; Exit Button
; ----------DEFINE MENU IDENTITIES------------
MyMenu equ 2000 ; Define Menu Identity
IDC_Edit1001 equ 1001
IDC_STATIC1002 equ 1002
IDM_Exit equ 1003
IDM_Help equ 1004
IDM_About equ 1005
; ---------------- END OF RESOURCE CONTROL DEFINITIONS --------------------------
;******************* DEFINE PROGRAM DATA with INITIALIZED VALUES *******************
.data
;--------------------------- DEFINE ZERO-TERMINATED STRINGS ----------------------------------------
DlgName db "MyDialog",0
MenuName db "MyMenu",0
MsgBoxTitle db "My Test Dialog Box ",0
About_String1 db "CueBanner Demo1/21/2025",0
Help_String db "Help (UNDER CONSTRUCTION).",0
Enter_String db "You Pressed Enter", 0
IDC_Edit1001CueBanner db "This is the CueBanner for IDC_Edit1001",0
;********************* DEFINE PROGRAM DATA with UNINITIALIZED VALUES *********************
.data?
; HANDLES
hInstance HINSTANCE ?
hDlg HWND ?
hCtrl HWND ?
CommandLine LPSTR ?
hIDC_Edit1001 HWND ?
;-----------------------------------------------------------------------------------------------------------------------------------------------------
BIGbuffer db 0FFFFh dup(?) ; Memory variable used to temporarily store data for further processing
;-------------------------------------------------------------------------------------------------------------------------------------------------------
dwPTR TYPEDEF PTR DWORD ; Use of "dwPTR" DATATYPE is KEY to defining PTR as a "POINTER"
lpIDC_Edit1001CueBanner dwPTR ?
;**************************************************************************************************************************************************
.code
;-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke DialogBoxParam, hInstance, addr DlgName,NULL, addr DlgProc, NULL ; Create Dialog Box
mov hDlg, eax ; Save the handle to the Dialog Box
INVOKE ExitProcess, eax
;******************************************************************************************************************************************************
DlgProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
;================================================================================
;============================= BEGIN MESSAGE LOOP ==============================
; Window Message -- Initialize Dialog Box
;--------------------------------------------------------------------------------------------------------------------------------------------
.IF uMsg==WM_INITDIALOG
invoke GetDlgItem,hWnd,IDC_Edit1001
mov hIDC_Edit1001,eax
LEA eax,IDC_Edit1001CueBanner
mov lpIDC_Edit1001CueBanner, eax
invoke SendMessage,hIDC_Edit1001,EM_SETCUEBANNER,lpIDC_Edit1001CueBanner,TRUE
;--------------------------------------------------------------------------------------------------------------------------------------------
.ELSEIF uMsg==WM_NOTIFY
push esi
mov esi,lParam
assume esi:ptr NMHDR
;------------------------------------------
.IF [esi].code==EN_MSGFILTER
assume esi:ptr MSGFILTER
;------------------------------------------
.IF [esi].msg==WM_LBUTTONDBLCLK
invoke GetFocus
mov hCtrl, eax
invoke GetDlgCtrlID,hCtrl
;=========================================
.ENDIF
;----------------------------------------------------------------------------------------------------------------
.ENDIF
;
; Window Message - Close Dialog Box (EXIT Program)
.ELSEIF uMsg==WM_CLOSE
invoke SendMessage,hWnd,WM_COMMAND,IDM_Exit,0
;--------------------------------------------------------------------------------------------------------------------------------------------
; Window COMMAND Messages
.ELSEIF uMsg==WM_COMMAND
mov eax,wParam
;========== Determine SOURCE of WM_COMMAND (MENU or BUTTON) ======================
.IF lParam==0
;=======================================================================
; SOURCE is MENU -- Determine Menu Option Selected
; BEGIN PROGRAM FLOW CONTROL VIA MENU SELECTIONS
;=======================================================================
MenuSelections:
;=======================================================================
.IF ax==IDM_Help
invoke MessageBox, NULL,ADDR Help_String, ADDR MsgBoxTitle,MB_OK
;-------------------------------------------------------------------------------------------------------------------------
.ELSEIF ax==IDM_About
invoke MessageBox,NULL,ADDR About_String1, ADDR MsgBoxTitle, MB_OK
;-------------------------------------------------------------------------------------------------------------------------
.ELSEIF ax==IDM_Exit
invoke EndDialog, hWnd,NULL
.ENDIF
;=======================================================================
.ELSE ; SOURCE is BUTTON -- Determine BUTTON Option Selected
;=======================================================================
mov edx,wParam
shr edx,16
.IF dx==BN_CLICKED
.IF ax==BTN_Enter
invoke MessageBox, NULL,ADDR Enter_String, ADDR MsgBoxTitle,MB_OK
.ELSEIF ax==BTN_Exit
invoke SendMessage,hWnd,WM_COMMAND,IDM_Exit,0
.ENDIF
.ENDIF
.ENDIF
.ELSE
mov eax,FALSE
RET
.ENDIF
mov eax,TRUE
RET
DlgProc ENDP
end start
;This Resource Script was generated by WinAsm Studio.
#include "resource.h"
#include "richedit.h"
#include "commctrl.h"
#define IDC_Edit1001 1001
#define IDC_STATIC1002 1002
#define IDM_Exit 1003
#define IDM_Help 1004
#define IDM_About 1005
#define BTN_Enter 1051
#define BTN_Exit 1052
#define MyMenu 2000
MyMenu MENUEX DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit",IDM_Exit
END
POPUP "&Help"
BEGIN
MENUITEM "&Help",IDM_Help
MENUITEM "&About",IDM_About
END
END
MYDIALOG DIALOGEX 10,10,400,200
CAPTION "CueBanner Demo Dialog Box"
FONT 8,"MS Shell Dlg"
MENU MyMenu
STYLE 0x90fb08d8
EXSTYLE 0x00000000
BEGIN
CONTROL "ENTER",BTN_Enter,"Button",NOT 0x00010000 | 0x10400000,63,105,50,20,0x00000000
CONTROL "EXIT",BTN_Exit,"Button",NOT 0x00010000 | 0x10400000,127,105,50,20,0x00000000
CONTROL "",IDC_Edit1001,"Edit",0x50810080,17,22,167,55,0x00000200
CONTROL "Plain Edit Control for CueBanner Demo",IDC_STATIC1002,"Static",0x50000000,20,83,164,10,0x00000000
END
Share
Improve this question
edited Jan 24 at 4:11
Larry Alongi
asked Jan 23 at 14:12
Larry AlongiLarry Alongi
14 bronze badges
3
|
1 Answer
Reset to default 0I must admit I'm not sure what a cuebanner should look like.
A "cue banner" (also referred to as a prompt) is text that is displayed in an edit control. It disappears when the user starts interacting with the control. Cue banners are conventionally used to display instructions or additional information to the user.
Sending the EM_SETCUEBANNER
to an edit control sets the cue banner for that control. This message is available starting with version 6.0 of the Common Controls library. Sending this message on earlier versions has no effect. To request version 6 (or later) of the Common Controls library a program must supply an Application Manifest that contains an appropriate dependency
.
The topic Enabling Visual Styles shows an example manifest with instructions for linking the manifest into the executable. These instructions assume a C++ compiler, and while the underlying principles are the same the specific steps may need to be slightly adjusted to compile and link assembly source code.
本文标签: winapiWhat does setting a cuebanner do and how do I get it to workStack Overflow
版权声明:本文标题:winapi - What does setting a cuebanner do and how do I get it to work? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738489267a2089610.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
EM_SETCUEBANNER
: "To use this API, you must provide a manifest specifying Comclt32.dll version 6.0. For more information on manifests, see Enabling Visual Styles." Since you're already using a resource script it shouldn't be difficult to add anRT_MANIFEST
. – IInspectable Commented Jan 23 at 14:46#include
WinUser.h or WinUser.rh either define constants forCREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST
as1
and24
respectively, or use numeric values in your resource script, e.g.1 24 "whatever.manifest"
. – IInspectable Commented Jan 25 at 8:43