News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Custom Opendialog error - help

Started by guga, December 18, 2012, 11:55:19 PM

Previous topic - Next topic

guga

Hi guys

I made a test on dougie file gdiptest and fixed a couple of things to make it work on winXP, but when the opendialog is erasing the icons when redraw (when i change the folder)

There is a problem when changing the folder when you open an image (opendialog). Strange behaviours shows up, and i can´t fix it right now. If someone knows how to fix it, please let me know
I attached the original masm files from dougiem0305. And inside the exe, i modified the hook function for opendialog, but it still have errors

as image below:

Image ok (Preview not show here...becauise i didn´t clicked the image )-
Image Fail - Once i changed the folder (uped a directory there is an error on drawing the opendialog)


[NMHDR.hwndFromDis 0
NMHDR.idFromDis 4
NMHDR.codeDis 8]

Proc ofnHookA:
    Arguments @hDlg, @uMsg, @wParam, @lParam
    Structure @OFNOTIFY 20, @OFNOTIFY.NMHDR_hwndFromDis 0, @OFNOTIFY.NMHDR_idFromDis 4, @OFNOTIFY.NMHDR_codeDis 8, @OFNOTIFY.lpOFNDis 12, @OFNOTIFY.pszFileDis 16
    Uses edi, esi, ecx

    ...If D@uMsg = &WM_COMMAND

        ;..If D@wParam = IDC_CHK01  ; adjust the chkState variable
        mov edx D@wParam
        movzx eax dx ; IDC_CHK01
        shr edx 16
        ..If_ANd eax = IDC_CHK01, edx = &BN_SETFOCUS;&BN_CLICKED

            call 'user32.SendMessageA' D$hChk1, &BM_GETCHECK, 0, 0

            If eax = 1
                call 'user32.SendMessageA' D$hChk1, &BM_SETCHECK, &BST_UNCHECKED, 0
                call 'user32.SetWindowTextA' D$hEd, 0
                call 'gdiplus.GdipGraphicsClear' D$GpvGraphics, D$BkGrnd
                call 'user32.SetWindowTextA' D$hTxt1, 0
                mov D$chkState 0
                ;mov D@OFNOTIFY.NMHDR_codeDis &CDN_SELCHANGE
                ;call 'user32.SendMessageA' D@hdlg, &WM_NOTIFY, IDC_CHK01, 0
            Else
                mov D$chkState 1
                call 'user32.SendMessageA' D$hChk1, &BM_SETCHECK, &BST_CHECKED, 0
                call ShowPreview
                ;call 'gdiplus.GdipGraphicsClear' D$GpvGraphics, D$BkGrnd
            End_If

            call 'user32.SetFocus' D$hWpv

        ..End_If

    ...Else_If D@uMsg = &WM_INITDIALOG

        call 'user32.GetParent' D@hDlg | mov D$sDlg eax
        call 'user32.GetDlgItem' D@hDlg, IDC_STATIC02 | mov D$hWpv eax
        call 'user32.GetDlgItem' D@hDlg, IDC_CHK01 | mov D$hChk1 eax
        call 'user32.GetDlgItem' D@hDlg, IDC_STATIC01 | mov D$hTxt1 eax
        ; "On" button initializted checked
        call 'user32.SendMessageA' D$hChk1, &BM_SETCHECK, &BST_CHECKED, 0
        ;If D$chkState <> 0
           
        ;End_If
        call 'gdiplus.GdipCreateFromHWND' D$hWpv, GpvGraphics
        call 'gdiplus.GdipGraphicsClear' D$GpvGraphics, D$BkGrnd
        mov eax 0

    ...Else_If D@uMsg = &WM_CLOSE

        call 'USER32.DestroyWindow' D@hDlg

    ...Else_If D@uMsg = &WM_NOTIFY

        ;mov eax D@wParam
        mov eax D@lParam
        mov ecx D$eax+NMHDR.codeDis
        ..If D$eax+NMHDR.codeDis = &CDN_FOLDERCHANGE
            ; this stops CDN_SELCHANGE from looking for a new image when folder change sends CDN_SELCHANGE
            call 'user32.SetWindowTextA' D$hEd, 0
            call 'gdiplus.GdipGraphicsClear' D$GpvGraphics, D$BkGrnd
            call 'user32.SetWindowTextA' D$hTxt1, 0
            mov D$chkState 0
            xor eax eax

        ..Else_If D$eax+NMHDR.codeDis = &CDN_SELCHANGE

            call 'user32.LoadCursorA' 0, &IDC_WAIT
            call 'user32.SetCursor' eax
            call WriteImageFormatString ansiTxt
            .If eax = &TRUE
                mov D$chkState 1
                call ShowPreview
                If eax <> 0
                    call filesize Edbuffer
                    shr eax 10 ; divide eax by 1024
                    C_call 'user32.wsprintfA' isize, isizeB, ansiTxt, D$pvW, D$pvH, eax
                    call 'user32.SetWindowTextA' D$hTxt1, isize
                    call 'user32.SendMessageA' D$hChk1, &BM_SETCHECK, &BST_CHECKED, 0
                End_If
            .End_If
           
            xor eax eax
        ..End_If

    ;...Else_If D@uMsg = &WM_PAINT
        ;xor eax eax
    ...Else_If D@uMsg = &WM_NCPAINT
        mov eax 0
    ...Else_If D@uMsg = &WM_SETREDRAW ; force redraw to avoid deleting controls
        mov eax &TRUE
    ...Else_If D@uMsg = &WM_ERASEBKGND
        xor eax eax   
    ...Else

        xor eax eax

    ...End_If

EndP



Proc GetFileName:
    Arguments @hParent, @lpTitle, @lpFilter, @custInfo

    ; Uses a resource template and a hook proc.
    ; Resizes/positions dlg window and draws a thumbnail size image

    move D$ofn.lCustData D@custInfo
    move D$ofn.hwndOwner D@hParent
    move D$ofn.hInstance D$hInstance
    move D$ofn.lpstrFilter D@lpFilter
    move D$ofn.lpstrFile szFileName
    mov D$ofn.nMaxFile 260
    move D$ofn.lpstrTitle D@lpTitle
    move D$ofn.lpfnHook ofnHookA
    mov D$ofn.Flags &OFN_EXPLORER__&OFN_HIDEREADONLY__&OFN_ENABLEHOOK__&OFN_ENABLESIZING__&OFN_ENABLETEMPLATE__&OFN_FILEMUSTEXIST
    ;mov D$ofn.Flags &OFN_EXPLORER__&OFN_HIDEREADONLY__&OFN_ENABLEHOOK__&OFN_ENABLETEMPLATE__&OFN_FILEMUSTEXIST
    mov D$ofn.lpTemplateName IDD_PREVIEW

    call 'comdlg32.GetOpenFileNameA' ofn
    push eax
        call 'gdiplus.GdipDeleteGraphics' D$GpvGraphics
    pop eax

EndP


The customized opendialog is resizable, but when redrawing the window (after i change the folder for opening a file) it is not redrawing it completelly

Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

qWord

It may be more helpful to upload the source of the broken program and not the source of whatever other program.
MREAL macros - when you need floating point arithmetic while assembling!