flat assembler
Message board for the users of flat assembler.

Index > Windows > New style windows???

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody
Anytime I make something like a button or whatever it always shows up in the old style, so I tried to use InitCommonControlsEx to enable the better style, but it doesn't work, I don't get any error from InitCommonControlsEx but nothing happens the style doesn't change

What's wrong? How do I enable the new style buttons, scrollbars, etc...?
Post 16 Feb 2008, 01:49
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 693
Location: Adelaide
sinsi
Search for "manifest"
Post 16 Feb 2008, 02:01
View user's profile Send private message Reply with quote
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody
thanks

I got it working when I place the XML in the same directory, but how do I get it working using a resource file?

The MSDN says use:

CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "YourApp.exe.manifest"

I tried:
Code:
section '.rsrc' resource data readable

directory RT_MANIFEST,manifest

resdata manifest
file 'YourApp.exe.manifest'
endres    
    


But it didn't work, although placing the XML in the same directory still works....
Post 16 Feb 2008, 02:19
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 693
Location: Adelaide
sinsi
You also need to call InitCommonControls, although looking here suggests maybe just importing it is OK.
Post 16 Feb 2008, 02:52
View user's profile Send private message Reply with quote
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody
sinsi wrote:
You also need to call InitCommonControls, although looking here suggests maybe just importing it is OK.


I called InitCommonControls and it works perfectly when I put the manifest file in the same directory

Thanks I found the problem it was with how I did the resource file
Post 16 Feb 2008, 03:00
View user's profile Send private message Reply with quote
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody
I got everything working with the file, now I'm trying to get it to work without using a file...

Why doesn't this work:
Code:
section '.rsrc' resource data readable

directory 24,manifest
resource  manifest,\
          1, LANG_NEUTRAL, winxp
resdata winxp
      ;  file 'manifest.xml'
db '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',13,10
db '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">',13,10
db '<assemblyIdentity',13,10
    db 'version="1.0.0.0"',13,10
    db 'processorArchitecture="X86"',13,10
    db 'name="CompanyName.ProductName.Application"',13,10
    db 'type="win32"',13,10
db  '/>',13,10
db '<description>Your application description here.</description>',13,10
db '<dependency>',13,10
    db '<dependentAssembly>',13,10
        db '<assemblyIdentity',13,10
            db 'type="win32"',13,10
            db  'name="Microsoft.Windows.Common-Controls"',13,10
            db 'version="6.0.0.0"',13,10
            db 'processorArchitecture="X86"',13,10
            db 'publicKeyToken="6595b64144ccf1df"',13,10
            db 'language="*"',13,10
       db  '/>',13,10
    db '</dependentAssembly>',13,10
db '</dependency>',13,10
db '</assembly>',0   
endres    
Post 16 Feb 2008, 03:35
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6034
Location: Poland
MHajduk
itsnobody wrote:
Why doesn't this work
Remove last zero byte from your manifest data definition, i.e. instead
Code:
db '</assembly>',0    
you should simply write
Code:
db '</assembly>'    
Here you have slightly improved 'DIALOG.ASM' example (from FASM 'EXAMPLES' directory) with included manifest data:
Code:
; DialogBox example

format PE GUI 4.0

include '%fasminc%\win32wx.inc'

ID_CAPTION     = 101
ID_MESSAGE     = 102
ID_ICONERROR           = 201
ID_ICONINFORMATION = 202
ID_ICONQUESTION    = 203
ID_ICONWARNING         = 204
ID_TOPMOST     = 301

section '.data' data readable writeable

  flags dd ?
  caption rb 40h
  message rb 100h

section '.code' code readable executable

  start:

    invoke  GetModuleHandle,0
   invoke  DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc,0
     or      eax,eax
     jz      exit
        invoke  MessageBox,HWND_DESKTOP,message,caption,[flags]
  exit:
      invoke  ExitProcess,0
       invoke  InitCommonControls

proc DialogProc hwnddlg,msg,wparam,lparam
 push    ebx esi edi
 cmp     [msg],WM_INITDIALOG
 je      .wminitdialog
       cmp     [msg],WM_COMMAND
    je      .wmcommand
  cmp     [msg],WM_CLOSE
      je      .wmclose
    xor     eax,eax
     jmp     .finish
  .wminitdialog:
     invoke  CheckRadioButton,[hwnddlg],ID_ICONERROR,ID_ICONWARNING,ID_ICONINFORMATION
   jmp     .processed
  .wmcommand:
     cmp     [wparam],BN_CLICKED shl 16 + IDCANCEL
       je      .wmclose
    cmp     [wparam],BN_CLICKED shl 16 + IDOK
   jne     .processed
  invoke  GetDlgItemText,[hwnddlg],ID_CAPTION,caption,40h
     invoke  GetDlgItemText,[hwnddlg],ID_MESSAGE,message,100h
    mov     [flags],MB_OK
       invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONERROR
   cmp     eax,BST_CHECKED
     jne     .iconerror_ok
       or      [flags],MB_ICONERROR
      .iconerror_ok:
    invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONINFORMATION
     cmp     eax,BST_CHECKED
     jne     .iconinformation_ok
 or      [flags],MB_ICONINFORMATION
      .iconinformation_ok:
        invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONQUESTION
        cmp     eax,BST_CHECKED
     jne     .iconquestion_ok
    or      [flags],MB_ICONQUESTION
      .iconquestion_ok:
      invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONWARNING
 cmp     eax,BST_CHECKED
     jne     .iconwarning_ok
     or      [flags],MB_ICONWARNING
      .iconwarning_ok:
        invoke  IsDlgButtonChecked,[hwnddlg],ID_TOPMOST
     cmp     eax,BST_CHECKED
     jne     .topmost_ok
 or      [flags],MB_TOPMOST
      .topmost_ok:
        invoke  EndDialog,[hwnddlg],1
       jmp     .processed
  .wmclose:
       invoke  EndDialog,[hwnddlg],0
  .processed:
  mov     eax,1
  .finish:
     pop     edi esi ebx
 ret
endp

.end start


section '.rsrc' resource data readable

  directory RT_DIALOG,dialogs,\
            24,manifest

  resource  manifest,\
            1, LANG_NEUTRAL, winxp

  resource  dialogs,\
         37,LANG_ENGLISH+SUBLANG_DEFAULT,demonstration

  dialog demonstration,'Create message box',70,70,190,175,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME
    dialogitem 'STATIC','&Caption:',-1,10,10,70,8,WS_VISIBLE
    dialogitem 'EDIT','',ID_CAPTION,10,20,170,13,WS_VISIBLE+WS_BORDER+WS_TABSTOP
    dialogitem 'STATIC','&Message:',-1,10,40,70,8,WS_VISIBLE
    dialogitem 'EDIT','',ID_MESSAGE,10,50,170,13,WS_VISIBLE+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL
    dialogitem 'BUTTON','&Icon',-1,10,70,80,70,WS_VISIBLE+BS_GROUPBOX
    dialogitem 'BUTTON','&Error',ID_ICONERROR,20,82,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON+WS_TABSTOP+WS_GROUP
    dialogitem 'BUTTON','I&nformation',ID_ICONINFORMATION,20,95,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON
    dialogitem 'BUTTON','&Question',ID_ICONQUESTION,20,108,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON
    dialogitem 'BUTTON','&Warning',ID_ICONWARNING,20,121,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON
    dialogitem 'BUTTON','&Style',-1,100,70,80,70,WS_VISIBLE+BS_GROUPBOX
    dialogitem 'BUTTON','&Top most',ID_TOPMOST,110,82,60,13,WS_VISIBLE+WS_TABSTOP+BS_AUTOCHECKBOX
    dialogitem 'BUTTON','OK',IDOK,85,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
    dialogitem 'BUTTON','C&ancel',IDCANCEL,135,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON
  enddialog

resdata winxp
        ;file 'manifest.xml'
db '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',13,10
db '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">',13,10
db '<assemblyIdentity',13,10
    db 'version="1.0.0.0"',13,10
    db 'processorArchitecture="X86"',13,10
    db 'name="CompanyName.ProductName.Application"',13,10
    db 'type="win32"',13,10
db  '/>',13,10
db '<description>Your application description here.</description>',13,10
db '<dependency>',13,10
    db '<dependentAssembly>',13,10
        db '<assemblyIdentity',13,10
            db 'type="win32"',13,10
            db  'name="Microsoft.Windows.Common-Controls"',13,10
            db 'version="6.0.0.0"',13,10
            db 'processorArchitecture="X86"',13,10
            db 'publicKeyToken="6595b64144ccf1df"',13,10
            db 'language="*"',13,10
       db  '/>',13,10
    db '</dependentAssembly>',13,10
db '</dependency>',13,10
db '</assembly>'
endres

    
It works perfectly for me. Smile
Post 16 Feb 2008, 10:43
View user's profile Send private message Visit poster's website Reply with quote
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody
MHajduk wrote:
itsnobody wrote:
Why doesn't this work
Remove last zero byte from your manifest data definition, i.e. instead
Code:
db '</assembly>',0    
you should simply write
Code:
db '</assembly>'    
Here you have slightly improved 'DIALOG.ASM' example (from FASM 'EXAMPLES' directory) with included manifest data:
Code:
; DialogBox example

format PE GUI 4.0

include '%fasminc%\win32wx.inc'

ID_CAPTION         = 101
ID_MESSAGE     = 102
ID_ICONERROR           = 201
ID_ICONINFORMATION = 202
ID_ICONQUESTION    = 203
ID_ICONWARNING         = 204
ID_TOPMOST     = 301

section '.data' data readable writeable

  flags dd ?
  caption rb 40h
  message rb 100h

section '.code' code readable executable

  start:

    invoke  GetModuleHandle,0
   invoke  DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc,0
     or      eax,eax
     jz      exit
        invoke  MessageBox,HWND_DESKTOP,message,caption,[flags]
  exit:
      invoke  ExitProcess,0
       invoke  InitCommonControls

proc DialogProc hwnddlg,msg,wparam,lparam
 push    ebx esi edi
 cmp     [msg],WM_INITDIALOG
 je      .wminitdialog
       cmp     [msg],WM_COMMAND
    je      .wmcommand
  cmp     [msg],WM_CLOSE
      je      .wmclose
    xor     eax,eax
     jmp     .finish
  .wminitdialog:
     invoke  CheckRadioButton,[hwnddlg],ID_ICONERROR,ID_ICONWARNING,ID_ICONINFORMATION
   jmp     .processed
  .wmcommand:
     cmp     [wparam],BN_CLICKED shl 16 + IDCANCEL
       je      .wmclose
    cmp     [wparam],BN_CLICKED shl 16 + IDOK
   jne     .processed
  invoke  GetDlgItemText,[hwnddlg],ID_CAPTION,caption,40h
     invoke  GetDlgItemText,[hwnddlg],ID_MESSAGE,message,100h
    mov     [flags],MB_OK
       invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONERROR
   cmp     eax,BST_CHECKED
     jne     .iconerror_ok
       or      [flags],MB_ICONERROR
      .iconerror_ok:
    invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONINFORMATION
     cmp     eax,BST_CHECKED
     jne     .iconinformation_ok
 or      [flags],MB_ICONINFORMATION
      .iconinformation_ok:
        invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONQUESTION
        cmp     eax,BST_CHECKED
     jne     .iconquestion_ok
    or      [flags],MB_ICONQUESTION
      .iconquestion_ok:
      invoke  IsDlgButtonChecked,[hwnddlg],ID_ICONWARNING
 cmp     eax,BST_CHECKED
     jne     .iconwarning_ok
     or      [flags],MB_ICONWARNING
      .iconwarning_ok:
        invoke  IsDlgButtonChecked,[hwnddlg],ID_TOPMOST
     cmp     eax,BST_CHECKED
     jne     .topmost_ok
 or      [flags],MB_TOPMOST
      .topmost_ok:
        invoke  EndDialog,[hwnddlg],1
       jmp     .processed
  .wmclose:
       invoke  EndDialog,[hwnddlg],0
  .processed:
  mov     eax,1
  .finish:
     pop     edi esi ebx
 ret
endp

.end start


section '.rsrc' resource data readable

  directory RT_DIALOG,dialogs,\
            24,manifest

  resource  manifest,\
            1, LANG_NEUTRAL, winxp

  resource  dialogs,\
         37,LANG_ENGLISH+SUBLANG_DEFAULT,demonstration

  dialog demonstration,'Create message box',70,70,190,175,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME
    dialogitem 'STATIC','&Caption:',-1,10,10,70,8,WS_VISIBLE
    dialogitem 'EDIT','',ID_CAPTION,10,20,170,13,WS_VISIBLE+WS_BORDER+WS_TABSTOP
    dialogitem 'STATIC','&Message:',-1,10,40,70,8,WS_VISIBLE
    dialogitem 'EDIT','',ID_MESSAGE,10,50,170,13,WS_VISIBLE+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL
    dialogitem 'BUTTON','&Icon',-1,10,70,80,70,WS_VISIBLE+BS_GROUPBOX
    dialogitem 'BUTTON','&Error',ID_ICONERROR,20,82,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON+WS_TABSTOP+WS_GROUP
    dialogitem 'BUTTON','I&nformation',ID_ICONINFORMATION,20,95,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON
    dialogitem 'BUTTON','&Question',ID_ICONQUESTION,20,108,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON
    dialogitem 'BUTTON','&Warning',ID_ICONWARNING,20,121,60,13,WS_VISIBLE+BS_AUTORADIOBUTTON
    dialogitem 'BUTTON','&Style',-1,100,70,80,70,WS_VISIBLE+BS_GROUPBOX
    dialogitem 'BUTTON','&Top most',ID_TOPMOST,110,82,60,13,WS_VISIBLE+WS_TABSTOP+BS_AUTOCHECKBOX
    dialogitem 'BUTTON','OK',IDOK,85,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
    dialogitem 'BUTTON','C&ancel',IDCANCEL,135,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON
  enddialog

resdata winxp
        ;file 'manifest.xml'
db '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',13,10
db '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">',13,10
db '<assemblyIdentity',13,10
    db 'version="1.0.0.0"',13,10
    db 'processorArchitecture="X86"',13,10
    db 'name="CompanyName.ProductName.Application"',13,10
    db 'type="win32"',13,10
db  '/>',13,10
db '<description>Your application description here.</description>',13,10
db '<dependency>',13,10
    db '<dependentAssembly>',13,10
        db '<assemblyIdentity',13,10
            db 'type="win32"',13,10
            db  'name="Microsoft.Windows.Common-Controls"',13,10
            db 'version="6.0.0.0"',13,10
            db 'processorArchitecture="X86"',13,10
            db 'publicKeyToken="6595b64144ccf1df"',13,10
            db 'language="*"',13,10
       db  '/>',13,10
    db '</dependentAssembly>',13,10
db '</dependency>',13,10
db '</assembly>'
endres

    
It works perfectly for me. Smile


Thanks it works perfectly, it's a lot better than using a file
Post 16 Feb 2008, 11:23
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
Below is what I see on my WinXPSP2 box, what do you see?
Post 16 Feb 2008, 11:39
View user's profile Send private message Visit poster's website Reply with quote
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody
revolution wrote:
Below is what I see on my WinXPSP2 box, what do you see?

hmm probably because WinXPSP2 requires you to InitCommonControls first. Without the manifest it looks just like yours.

on Windows Vista I see:


Description:
Filesize: 7.58 KB
Viewed: 2747 Time(s)

winvista.png


Post 16 Feb 2008, 11:47
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
itsnobody wrote:
hmm probably because WinXPSP2 requires you to InitCommonControls first.
Okay, I moved the InitCommonControls right up to the first line after "start:", but I get no change in the appearance. Is this a Vista only thing?
Post 16 Feb 2008, 11:52
View user's profile Send private message Visit poster's website Reply with quote
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody
revolution wrote:
itsnobody wrote:
hmm probably because WinXPSP2 requires you to InitCommonControls first.
Okay, I moved the InitCommonControls right up to the first line after "start:", but I get no change in the appearance. Is this a Vista only thing?


No it supposed to work for XP too, unless you have your theme on XP set to only have classic style buttons (source http://www.vbaccelerator.com/home/vb/code/libraries/XP_Visual_Styles/Using_XP_Visual_Styles_in_VB/article.asp )

Try this:
Code:
  s:
  init INITCOMMONCONTROLSEX t-s,0xFF+0x200+4000;ICC_WIN95_CLASSES+ICC_USEREX_CLASSES+ICC_STANDARD_CLASSES
  t:
    

Code:
        invoke InitCommonControlsEx,init
    


Does that change anything?
Post 16 Feb 2008, 11:58
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
I do have my theme as classic style buttons.

The extra "InitCommonControlSex" thing gives no change at all.
Post 16 Feb 2008, 12:35
View user's profile Send private message Visit poster's website Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6034
Location: Poland
MHajduk
revolution
On my Windows XP SP2 it works correct. As itsnobody said, you should check settings of windows display ('classic style' or 'XP style').


Description:
Filesize: 6.06 KB
Viewed: 2735 Time(s)

dialog.png


Post 16 Feb 2008, 12:35
View user's profile Send private message Visit poster's website Reply with quote
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody
revolution wrote:
I do have my theme as classic style buttons.

The extra "InitCommonControlSex" thing gives no change at all.


Hmm...then InitCommonControls is pretty useless, unless you need for other controls
Post 16 Feb 2008, 12:39
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
You ought to call InitCommonControlsEx . Don't think that just because not calling it works on some windows systems, it will work on all.
Post 16 Feb 2008, 14:13
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
f0dder: That link is true for C/HLLs, because the compiler is trying to be smart and optimise away an unused reference to a DLL. In assembly we can easily force a DLL to be included without really having to call a function.
Code:
virtual
call InitCommonControls
end virtual    
But note that the ex version does do something useful so of course that will need to be called for real.
Post 16 Feb 2008, 14:46
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
I think you missed my point, revolution. That just because not calilng InitCommonControls() isn't necessary on your windows version doesn't mean it'll always be that way.

And for the windows versions where it doesn't do anything, what the fuck is the problem of calling it, anyway? You only need it once at startup, and if it just does "ret", you're not really wasting any time.

People applying idiotic "optimizations" like this is one of the major reasons that software breaks on, for instance, 64-bit windows versions, or non-admin accounts.
Post 16 Feb 2008, 16:31
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
It is probably just the thought of doing unnecessary things that makes some people want to "stop the nonsense". InitCommonControls only exists because of the HLL optimisation layer. If the HLL did not optimise then things like InitCommonControls would never be needed.

I kind of view assembly as the ultimate level of optimisation, and it is probably habit that has made me mindful of wasted things.

But I am not arguing against you, you are correct, one simple call to InitCommonControls shoulld be a no-brainer.
Post 16 Feb 2008, 16:55
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
revolution wrote:
It is probably just the thought of doing unnecessary things that makes some people want to "stop the nonsense". InitCommonControls only exists because of the HLL optimisation layer. If the HLL did not optimise then things like InitCommonControls would never be needed.


No, you are inferring that from how windows works today. MSDN/PlatformSDK doesn't say that "you only need to make sure comctl32.dll is loaded, you don't need to call InitCommonControls()".

But of course there's a good chance that InitCommonControls will never ever do anything, because so many people have been following foolish advice.
Post 16 Feb 2008, 17:04
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.