News:

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

Static bitmap

Started by loser1, March 19, 2006, 02:04:47 PM

Previous topic - Next topic

loser1

I have used the search on the site and i am unable to find the answers to my problem. my problem is it isnt setting the bitmap to the static control heres my source maybe someone can find what im doing wrong.

[attachment deleted by admin]

PBrennick

The attached file is from the masm32 distro.  It is one of the examples and it shows how to put a bitmap onto a button.

Paul


[attachment deleted by admin]
The GeneSys Project is available from:
The Repository or My crappy website

loser1

i am not trying to do a bitmap button im trying to set a bitmap image to a static control. Which i have done in the above example. I'm just asking what is wrong with it. So if theres anyone who has time and can help it would be much appreciated heres the code.

Quote


[rsrc.rc]

#include "C:\masm32\include\resource.h"
101 DIALOGEX 6, 6, 400, 290
STYLE DS_CENTER | WS_POPUP | WS_SYSMENU
CAPTION ""
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "Exit", 103, STATIC, BS_BITMAP | SS_BLACKFRAME  WS_CHILD | WS_VISIBLE | WS_TABSTOP, 45, 192, 90, 11
END

102 BITMAP MOVEABLE PURE LOADONCALL DISCARDABLE "1.bmp"



[test.asm]
.486                 
.model flat, stdcall 
option casemap :none

   include    C:\masm32\include\windows.inc
   include    C:\masm32\include\kernel32.inc
   include    C:\masm32\include\user32.inc
   include    C:\masm32\include\gdi32.inc

   includelib C:\masm32\lib\kernel32.lib
   includelib C:\masm32\lib\user32.lib
   includelib C:\masm32\lib\gdi32.lib

DlgProc      PROTO :HWND, :UINT, :WPARAM,:LPARAM
Write      PROTO :DWORD,:DWORD,:DWORD

.DATA

abouttext  db "f1",0
aboutcap   db "you pressed f1",0
abouttext2 db "f2",0
aboutcap2  db "you pressed f2",0

.DATA?
   hInstance     dd ?
   statichwnd     dd ?
   bitmaphwnd   dd ?

.CODE
start:
   invoke      GetModuleHandle,NULL
   mov         hInstance,eax
   invoke      DialogBoxParam,hInstance,101,NULL,addr DlgProc,NULL
   invoke      ExitProcess,0

DlgProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

   cmp      [uMsg],WM_INITDIALOG
   jne      @1
        invoke    SetTimer,hWin,1,90,0
        invoke    GetDlgItem,hWin,103
   mov       statichwnd,eax
   invoke    LoadBitmap,hInstance,102
   mov       bitmaphwnd,eax
   invoke    SendMessage,statichwnd,BM_SETIMAGE,0,bitmaphwnd

   @1:
   cmp     [uMsg],WM_CLOSE
   jne     @2
   invoke     ExitProcess,0
   @2:
   cmp       [uMsg],WM_COMMAND
   jne       @3
   cmp       [wParam],103
   jne      @end
   invoke     ExitProcess,0
   @3: 
        cmp       [uMsg],WM_TIMER
        jne      @4
        invoke    GetAsyncKeyState,VK_F1
        cmp       eax,0
        jz        @end
          invoke      MessageBox, NULL, addr abouttext, addr aboutcap, MB_ICONINFORMATION
   @4:     
        invoke    GetAsyncKeyState,VK_F2
        cmp       eax,0
        jz        @end
          invoke      MessageBox, NULL, addr abouttext2, addr aboutcap2, MB_ICONINFORMATION
   @end:
   xor     eax,eax
   ret

DlgProc endp

end start
[/pre]

hutch--

I gather you want to learn how its done rather than just use a proc that does it but its easy enough to get going. Create a static window (label) with the SS_BITMAP style and then load the image into the static control with the STM_SETIMAGE message. You can see exactly how its done with the DisplayBmp() procedure in the masm32 library as all of the source code is available.


Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

loser1

hutch the dbmp source in the masm library was exactly what i needed thank you.

hutch--

Only run these styles.


SS_BITMAP | WS_CHILD | WS_VISIBLE


SS_BITMAP excludes the rest.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

loser1