WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
What is FASM G
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
Forum Rules Snippets forum rules

In this forum all the registered users may post their snippets of code they whish to share with the WinAsm Studio community following these basic rules:
* Only snippets of code are accepted in the topics of this forum.
* Discussions, suggestions, requests etc. must be posted in the "Discussions" topic.
* Do not post copyrighted material.
Administrators/moderators may edit, move or delete the entries that do not follow the preceding rules.

Pages (2) [1] 2   ( Go to first unread post )

MessageBox with a custom icon, a code snippet that allows you to display a message box with any icon of your choice.

Jupiter
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 745
Member No.: 773
Joined: 10-November 04


CODE

MsgBox  Proto hWndM:HWND, sMsgTxt:LPSTR, sCaption:LPSTR, dStyle:DWORD, dIcon:DWORD

MessageBox
Show MessageBox with custom icon
Syntax:
MsgBox  Proto hWndM:HWND, sMsgTxt:LPSTR, sCaption:LPSTR, dStyle:DWORD, dIcon:DWORD
Parameters:
[IN] HWND hWndM - Main HWND
[IN] LPSTR sMsgTxt - Message to display
[IN] LPSTR sCaption - Message Caption
[IN] DWORD dStyle - Style, standard MessageBox constants
[IN] DWORD dIcon - Icon ID
Returns:
MessageBoxIndirect return value
Example:
invoke MsgBox, hWnd, addr szAboutApp, addr szAboutCap, MB_OK, IDI_MAIN


See attachment:

Attached File ( Number of downloads: 202 )
 Login or Register to download

Sponsored Links
PMEmail Poster
Top
0x3a
Quote Post


New Member
*

Group: Members
Posts: 6
Member No.: 30940
Joined: 14-January 10


Doesn't seem to work, when I do 0 for the hIcon it does work, but whenever I do for example IDI_ICON which is a constant equ 100 nothing happends anymore..
PMEmail Poster
Top
SeaFarer
Quote Post


Extremely Active Member
******

Group: Members
Posts: 1753
Member No.: 1464
Joined: 2-September 05


I've not used this myself, but have you defined the IDC_ICON resource and assigned an actual icon to it?

Is so you...


Then need to load the icon since hIcon is a handle for the loaded IDC_ICON resource.

See the LoadIcon function in the API References.

Does this help you? :coder
PM
Top
0x3a
Quote Post


New Member
*

Group: Members
Posts: 6
Member No.: 30940
Joined: 14-January 10


Yes I am loading the icon as well, using:
CODE
invoke  LoadIcon,hInstance,IDI_ICON


This happends in my main dialog handler, after that I use an about button
like so:
CODE
    .if eax==IDI_BUTTONABOUT
     invoke MsgBox,0, addr g_AboutInfo, addr g_AboutTitle, MB_OK,IDI_ICON;
    .endif


But with IDI_ICON it doesn't work, when I just place a 0 there it skips the custom icon and just shows a normal popup.

PMEmail Poster
Top
0x3a
Quote Post


New Member
*

Group: Members
Posts: 6
Member No.: 30940
Joined: 14-January 10


I fixed it, this works for me:

CODE
; ------------------------------------------------------
; Name: MsgBox
; Desc: Show a messagebox with a custom icon

MsgBox Proc hWndM:HWND, sMsgTxt:LPSTR, sCaption:LPSTR, dStyle:DWORD, dIcon:DWORD
Local MsgBoxP :MSGBOXPARAMS

Ifdef TranspWnd
.If VerInfo.dwMajorVersion >= 5
 invoke SetWndTransp, hWndM, TR_INACTIVE
.EndIf
EndIf

push edi
lea edi, MsgBoxP
assume edi: ptr MSGBOXPARAMS
mov [edi].cbSize, sizeof MSGBOXPARAMS
mov [edi].hwndOwner, 0
m2m [edi].hInstance, hInstance
m2m [edi].lpszText, sMsgTxt
m2m [edi].lpszCaption, sCaption
mov [edi].dwStyle, MB_OK or MB_USERICON
m2m [edi].lpszIcon, dIcon

assume edi: nothing
invoke MessageBoxIndirect, edi
pop edi

Done:
Ifdef TranspWnd
.If VerInfo.dwMajorVersion >= 5
 push eax
 invoke SetWndTransp, hWndMain, TR_ACTIVE
 pop eax
.EndIf
EndIf
ret
MsgBox EndP



For anyone who has the same problems :)
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Pages (2) [1] 2  Reply to this topicStart new topic

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google