The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: travism on May 17, 2009, 09:13:29 AM

Title: ChooseColor Causes application to die
Post by: travism on May 17, 2009, 09:13:29 AM
So I decided to use a choosecolor dialog box, mind you im using the newest headers from the goasm headers project. Here is my code, It doesnt give me any errors but when i click the button for it to show the colors dialog box it causes the program to exit with error.


DATA SECTION
           cColor  CHOOSECOLORA <?>            ; I have to choose CHOOSECOLORA or CHOOSECOLORW, or is it gives me a error.
CODE SECTION
          cmp d[uMsg],WM_COMMAND
          jne >TRUE
                   cmp d[uMsg],IDC_CHOOSECOLORS
                    jne >FALSE

                            invoke ZeroMemory,addr cColor,sizeof(cColor)
                            mov     d[cColor.lStructSize],sizeof(cColor)
                            push    [hWnd]
                            pop      [cColor.hwndOwner]
                            mov      d[cColor.Flags],CC_PREVENTFULLOPEN
                           invoke  ChooseColor,addr cColor
          jmp >TRUE


Im guessing it has to do with how the structure was defined in the headers? or am I doing something wrong here?
Title: Re: ChooseColor Causes application to die
Post by: Mark Jones on May 20, 2009, 02:16:21 AM
Quote from: travism on May 17, 2009, 09:13:29 AM

CODE SECTION
          cmp d[uMsg],WM_COMMAND
          jne >TRUE



As Utillmasm would say, "Oh my fo!" :bg

TRUE and FALSE should be defined to be numeric constants, do these branches work as expected? I see no .LABEL (local label) declarations. Perhaps try making the conditions more like the form of:
http://www.masm32.com/board/index.php?topic=11097.msg85520#msg85520

Do you use OllyDbg? If so, try stepping through the offending code. That's the easiest way to tell exactly what is going on.