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

;     include files
;     ~~~~~~~~~~~~~
      include \masm32\include\windows.inc
      include \masm32\include\masm32.inc
      include \masm32\include\gdi32.inc
      include \masm32\include\user32.inc
      include \masm32\include\kernel32.inc
      include \masm32\include\Comctl32.inc
      include \masm32\include\comdlg32.inc


;     libraries
;     ~~~~~~~~~
      includelib \masm32\lib\masm32.lib
      includelib \masm32\lib\gdi32.lib
      includelib \masm32\lib\user32.lib
      includelib \masm32\lib\kernel32.lib
      includelib \masm32\lib\Comctl32.lib
      includelib \masm32\lib\comdlg32.lib
      
;-------------------------------------------------------------------

;     include \masm32\include\debug.inc
;     includelib \masm32\lib\debug.lib

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

        ;=================
        ; Local prototypes
        ;=================
        WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
        TopXY PROTO :DWORD,:DWORD
        Paint_Proc       PROTO :DWORD
        AboutProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
        
        wsprintfA PROTO C :DWORD,:VARARG
        wsprintf equ <wsprintfA>

      ;=============
      ; Local macros
      ;=============
      
$invoke MACRO Fun:REQ, A:VARARG
  IFB <A>
    invoke Fun
  else
    invoke Fun, A
  endif
  exitm <eax>
ENDM

      m2m MACRO M1, M2
        push M2
        pop  M1
      ENDM

      return MACRO arg
        mov eax, arg
        ret
      ENDM

    ; --------------------------------------------
    ; Возврвщает старшее слово
    ; --------------------------------------------
    HIWORD  MACRO   bigword ;; Retrieves the high word from double word argument

    mov ebx,bigword
    shr ebx,16      ;; Shift 16 for high word to set to high word
                
    ENDM

    ; ------------------------------------------------
    ; Возврвщает младщее слово
    ; ------------------------------------------------
      LOWORD MACRO bigword  
        mov  eax,bigword
        and  eax,0FFFFh     ; Set to low word 
      ENDM


     .data
        szDisplayName db "Example of Scrolling a Bitmap",0
        szClassName db "SCROLL_CLASS",0
        szOpenTitle db "Open A File",0
        szFilter db "BMP",0,"*.bmp",0

                        
    .data?
        hInstance dd ?
        hIcon dd ?
        hCursor dd ?
        sWid dd ?
        sHgt dd ?
        hWnd dd ?
        
        hMemDC HDC ?
        hBitmap HBITMAP ?
        hBitmapOld HBITMAP ? 
        nWidth dd ?
        nHeight dd ? 
        nHorizDiff dd ?
        nVertDiff dd ?
        nHorizPos dd ?                          ; current horizontal scroll value
        nVertPos dd ?                           ; current vertical scroll value

        fScroll db ? 

    .const
    
        ID_MENU equ 600
        IDM_OPEN equ 1000
        IDM_EXIT equ 1002
        IDM_ABOUT equ 1900
        IDD_ABOUT equ 800
; ########################### Inserted modules ############################ 
        
      include Filedlgs.asm            