News:

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

BitBlt on static control??

Started by ragdog, July 03, 2007, 05:14:59 PM

Previous topic - Next topic

ragdog

hello guys

I would like draw BitBlt bitmap in static a control
it´s works not correct
can give their me a tip?


ragdog

[attachment deleted by admin]

drizz

You must paint the static in its own WM_PAINT, then it will work.

replace the asm file with this code
.386
.model flat, stdcall  ;32 bit memory model
option casemap :none  ;case sensitive

include Dlg.inc

.code

start:
invoke GetModuleHandle,NULL
mov hInstance,eax
    invoke InitCommonControls
invoke DialogBoxParam,hInstance,IDD_DIALOG1,NULL,addr DlgProc,NULL
invoke ExitProcess,0

;########################################################################

StcProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL hOldBmp
.if uMsg == WM_PAINT
invoke BeginPaint, hMain,addr  MainPS
mov hMainDC, eax
invoke CreateCompatibleDC, eax
mov hMemDC, eax
invoke CreateCompatibleBitmap, hMainDC, 234, 16
mov hBitmap,eax
invoke SelectObject, hMemDC, hBitmap
mov hOldBmp,eax
invoke CreateSolidBrush,  066FF66h
mov hBrush,eax
invoke SelectObject, hMemDC, hBrush
invoke Rectangle, hMemDC, 0, 0, 234, 16
invoke BitBlt, hMainDC, 0, 0, 234, 16, hMemDC, 0, 0, SRCCOPY
invoke SelectObject, hMemDC, hOldBmp
invoke DeleteObject, hBitmap
invoke DeleteObject, hBrush
invoke DeleteDC, hMemDC
invoke EndPaint, hMain, addr MainPS
xor eax,eax
ret
.endif
invoke GetWindowLong,hMain,GWL_USERDATA
invoke CallWindowProc,eax,hWin,uMsg,wParam,lParam
ret
StcProc endp

DlgProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
mov eax,uMsg
.if eax==WM_INITDIALOG
invoke GetDlgItem,hWin,1001
mov hMain,eax
invoke SetWindowLong,hMain,GWL_WNDPROC,offset StcProc
invoke SetWindowLong,hMain,GWL_USERDATA,eax
.elseif eax==WM_CLOSE
invoke EndDialog,hWin,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret

DlgProc endp

end start
The truth cannot be learned ... it can only be recognized.

ragdog

thx drizz

you have a solution for just everything brilliant :bg :U

regards
ragdog

six_L

.386
.model flat, stdcall  ;32 bit memory model

option casemap :none  ;case sensitive
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\gdi32.inc
include \masm32\include\Comctl32.inc
include \masm32\include\shell32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\Comctl32.lib
includelib \masm32\lib\shell32.lib

.const
IDD_DIALOG1 equ 101
IDC_BITMAP equ 2000
IDC_BITMAP1 equ 2001

.data?
hInstance dd ?
hStatic dd ?
hBitmap dd ?
hBitmap1 dd ?
bmpFlag BOOL ?

.code
DlgProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
local hSticDC:HDC
local hMemDC:HDC
local hTmpBitmap:HANDLE

mov eax,uMsg
.if eax==WM_INITDIALOG
invoke SetTimer,hWin,200,1000,0
        invoke GetDlgItem,hWin,1001
mov hStatic,eax

invoke LoadBitmap,hInstance,IDC_BITMAP
mov hBitmap,eax
invoke LoadBitmap,hInstance,IDC_BITMAP1
mov hBitmap1,eax
mov bmpFlag,TRUE
.elseif eax == WM_TIMER
        invoke GetWindowDC, hStatic
             mov hSticDC, eax
        invoke CreateCompatibleDC, eax
             mov hMemDC, eax
.if bmpFlag==TRUE
push hBitmap
pop hTmpBitmap
mov bmpFlag,FALSE
.else   
push hBitmap1
pop hTmpBitmap
mov bmpFlag,TRUE
.endif 
        invoke SelectObject, hMemDC, hTmpBitmap
          invoke BitBlt, hSticDC, 10, 10, 120, 122, hMemDC, 10, 10, SRCCOPY
          invoke DeleteObject, hMemDC
                invoke ReleaseDC,hStatic,hSticDC
.elseif eax==WM_CLOSE
          invoke DeleteObject, hBitmap
          invoke DeleteObject, hBitmap1
invoke KillTimer,hWin,200
invoke EndDialog,hWin,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret

DlgProc endp

start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke InitCommonControls
invoke DialogBoxParam,hInstance,IDD_DIALOG1,NULL,addr DlgProc,NULL
invoke ExitProcess,0

end start


#define IDD_DIALOG1 101
#define IDC_STC1 1001
#define IDC_BTN1 1002
#define IDC_BTN2 1003
#define IDC_BITMAP_1 2000
#define IDC_BITMAP_2 2001
IDD_DIALOG1 DIALOGEX 6,6,194,115
CAPTION "DialogApp"
FONT 8,"MS Sans Serif",0,0
STYLE 0x10CF0800
EXSTYLE 0x00000000
BEGIN
  CONTROL "",IDC_STC1,"Static",0x50000001,2,2,188,90,0x00020000
  CONTROL "IDC_BTN",IDC_BTN1,"Button",0x50010000,6,95,40,18,0x00000000
  CONTROL "IDC_BTN",IDC_BTN2,"Button",0x50010000,50,95,40,18,0x00000000
END
IDC_BITMAP_1 BITMAP    DISCARDABLE "test.bmp"
IDC_BITMAP_2 BITMAP    DISCARDABLE "xxx.bmp"

[attachment deleted by admin]
regards

hutch--

ragdog,

Just keep in mind that a static control is a very simple control and you can write your own version with CreateWindowEx() that can do more and give you a lot more flexibility in what you can do with it. Blit your own image data to it, trap mouse move or click events, effectively the whole range of messages sent to a window.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ragdog