RadASM 3.x - How do I add Icons to Project? (Solved)

Started by Shooter, December 05, 2010, 09:08:25 PM

Previous topic - Next topic

Shooter

Two more questions about RadASM (3.x):

1) How do I add an icon to a project?

I would've thought it would be in the "Resource | Add New >" area.

2) How do I set the new icon to a dialog box?


Thanks,
-Shooter
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

Gunner

Double click on your rc file to open in editor, then click (menu)Resource -> Resource Files click the  button add, Type = icon, name = whatever For the example it is named ICON_MAIN, Id = some#, and filename=self explanatory.. now in your code in WM_INITDIALOG:

invoke LoadImage, hInst, ICON_MAIN, IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR
invoke SendMessage, hWin, WM_SETICON,ICON_BIG, eax
invoke LoadImage, hInst, ICON_MAIN, IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR
invoke SendMessage, hWin, WM_SETICON,ICON_SMALL, eax


~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

Shooter

Thank you very much, Gunner. This is the actual code I used:

WMINITDIALOG:
      CMP EAX,WM_INITDIALOG
      JNE >WMCOMMAND
ADDICONS:
      INVOKE LoadImage, [hInst], 100, IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR
      INVOKE SendMessage, [hwnd], WM_SETICON,ICON_SMALL, eax

Now I'm trying to add an image to the dialog that I added as an icon (same size as the one above, but different image) and set it's ID to 101. However, the location for the image (ID=1013) turns out blank when I run the dialog. I tried this code, but it didn't work:

      INVOKE LoadImage, [hInst], 101, IMAGE_BITMAP, 48, 48, LR_DEFAULTCOLOR
      MOV eax, 1013
      INVOKE SendMessage, [hwnd], WM_SETICON, ICON_BIG, eax


I didn't know if there was another WM_SET___ that I could try... nothing popped up that looked promising. Got any ideas?

-Shooter
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

Gunner

WM_SETICON only sets the icon for the title bar and taskmenu/taskbar and whatever else shows the program info while running...  If you are trying to set the exe icon then just create an icon with 16x16, 32x32, 48x48 formats and add it to your resource file with the id of 1 then your 48x48 icon will show on the desktop

QuoteAn application sends the WM_SETICON message to associate a new large or small icon with a window. The system displays the large icon in the ALT+TAB dialog box, and the small icon in the window caption.
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

donkey

Adding an image to a dialog is not as simple as setting an icon. You will need a container for the image, usually a static or "picture box". And you will probably end up having to paint the image yourself if it is not static. Otherwise use a static control with the SS_BITMAP style.
"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

Shooter

Gunner,
Actually I've added an image to the dialog box that I eventually want to cycle some images through with a click of a button. I'm building a sample project that contains a variety of controls so I can use them later... this is just for training and education as I'm trying to get reacquainted with Assembly Language, but build programs for Windows.

(See Attached)

-Shooter
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

donkey

Assuming that the box where you want the image is a static control set the style to SS_BITMAP | SS_CENTERIMAGE then use the STM_SETIMAGE to assign an image to it.

EDIT: If you're using RadAsm's Image control set the alignment to "center" and the Type to "Bitmap", it's just a static control btw.
"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

Shooter

Quote from: donkey on December 05, 2010, 10:48:08 PM
Assuming that the box where you want the image is a static control set the style to SS_BITMAP | SS_CENTERIMAGE then use the STM_SETIMAGE to assign an image to it.

EDIT: If you're using RadAsm's Image control set the alignment to "center" and the Type to "Bitmap", it's just a static control btw.

Edgar,
Haha, I had already gone and made sure that the SS_BITMAP | SS_CENTERIMAGE were selected by the time you edited your post.

I did find that upon the 'image' creation to the RC file, the 'Visible' flag was set to false somehow. I changed it and now the image shows. I still want to know how to change the image now that it's showing, however, using STM_SETIMAGE is throwing me off (I'm not sure of it's syntax or usage, yet).

-Shooter
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

donkey

Hi Shooter,

Click on STM_SETIMAGE in my post above for syntax help.
"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

Shooter

Quote from: donkey on December 06, 2010, 03:38:10 AM
Hi Shooter,

Click on STM_SETIMAGE in my post above for syntax help.

Edgar,
My apologies, but perhaps what others see as syntax isn't what I see. STM_SETIMAGE may require 2 parameters, but do you call it, invoke it, SendMessage to it, SendDlgItemMessage to it (or reference it), say, "Hey Mr. STM_SETIMAGE, would you please change my image?" lol.

That link sent me to a page that, as far as I'm used to, does not contain any syntax or usage, just a description. I'm just a poor boy on the farm of knowledge and hadn't quite come across this path before. ;) Now, I ain't sayin' that I'm ignorant, just naive.  :bg

-Shooter
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

Gunner

i usually say yo, set this image ;)   the page says an app SENDS this message, so use send message or senddlgitemmessage....  call it or invoke it...whatever you want off the top of my head, so i might be wrong...   invoke sendmessage, hctrl, stm_setimage, image_bitmap, hbitmap        and you have to free the image handle it returns if not 0 
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

Shooter

Welp, this is they I've got it coded (shortened up for forum purposes), but it ain't doin' anything.


DlgProc FRAME hwnd,uMsg,wParam,lParam
   MOV EAX,[uMsg]
WMINITDIALOG:
      CMP EAX,WM_INITDIALOG
      JNE >WMCOMMAND
      INVOKE  LoadBitmap,[hInst], 101     ; 101 is the first bitmap IDC number
      MOV     [hBmp1], EAX
      INVOKE  LoadBitmap,[hInst], 102     ; 102 is the second bitmap IDC number
      MOV     [hBmp2], EAX
      JMP >EXIT
WMCOMMAND:
      CMP EAX,WM_COMMAND
      JNE >WMCLOSE
Button4_Click:                         
      MOV EAX,[wParam]           ; Load handle
      CMP EAX,1014                  ; Check to see if 'Swap Button' was clicked
      JNE >Quit                        ; Skip if not clicked
      INVOKE SendDlgItemMessage,[hwnd],1013,STM_SETIMAGE, IMAGE_BITMAP, OFFSET hBmp2 ; Change IDC 1013 (img)
      JMP >EXIT                       ; Get out of here
WMCLOSE:
      CMP EAX,WM_CLOSE
      JNE >DEFPROC
      INVOKE EndDialog,[hwnd],0
DEFPROC:
      mov EAX,FALSE
      RET
EXIT:

   MOV EAX, TRUE
   RET
DlgProc ENDF


I tried yellin' at the monitor a little, but it wasn't havin' any of that.  :eek

So, what am I doing wrong?

-Shooter
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

donkey

Hi Shooter,

You almost got it, you send the actual value of hBmp, not the offset:

INVOKE SendDlgItemMessage,[hwnd],1013,STM_SETIMAGE, IMAGE_BITMAP, [hBmp2]

Edgar
"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

Shooter

Edgar,
I made that change, and it compiled just fine, but when I ran it the first time, my computer basically locked up. I rebooted and checked some things out and didn't find anything wrong. So I re-launched it, and this time the CPU usage is hanging around 98%. I was able to force it to shut down (task manager), and now I'm here.

I'm attaching the project for review, but I've got to get some sleep... got several hours of traveling for work tomorrow.

If you happen to try it out, please let me know if it hangs on you as well.

Again, many thanks,
-Shooter
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

donkey

The project you attached is the old one with moduleproc and gfl.txt in it. But looking at the code above I would check the following line:

      JNE >Quit                        ; Skip if not clicked

Where is the Quit label ?

Edgar
"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