flat assembler
Message board for the users of flat assembler.

Index > Windows > Templated GetSave/OpenFileName

Author
Thread Post new topic Reply to topic
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek 27 Jun 2012, 09:42
Hello, All!

I'm struggling to add controls to the standard GetOpenFileName GetSaveFileName window, but nothing comes out, system keeps ignoring my attempts. Here's the simple code. As could be seen from the source, I'm trying to add a radiobutton 'Test' to the standard SaveFileName window, but nothing happens:

Code:
format PE GUI 4.0
entry start
include 'win32a.inc'

TEMPLATE_DLG = 47

section '.text' code readable executable
start:
     invoke  GetModuleHandle,0
   mov     [hInstance],eax
     mov     [ofn.hInstance],eax

     mov     [ofn.Flags],OFN_EXPLORER+OFN_PATHMUSTEXIST+OFN_ENABLETEMPLATE
       mov     [ofn.lpTemplateName],TEMPLATE_DLG

       invoke  GetSaveFileName,ofn

     invoke  ExitProcess,0

section '.data' data readable writeable

  _filter TCHAR 'Text Files (*.txt)',0,'*.txt',0,0

  ofn       OPENFILENAME sizeof.OPENFILENAME,0,0,_filter,0,0,0,filename,MAX_PATH

  hInstance dd ?
  filename      db MAX_PATH dup (?)


section '.rsrc' resource  data readable 
  directory RT_DIALOG,dialogs

  resource dialogs,\
     TEMPLATE_DLG,LANG_NEUTRAL,template_dlg

  dialog template_dlg,'',0,0,150,100,WS_CLIPSIBLINGS+DS_CONTROL+DS_3DLOOK
    dialogitem 'BUTTON','Test',100,6,3,54,9,WS_CHILD+WS_VISIBLE+BS_RADIOBUTTON
  enddialog



section '.idata' import data readable
  library kernel32,'KERNEL32.DLL',\
       user32,'USER32.DLL',\
    comdlg32,'COMDLG32.DLL'

  include 'api/kernel32.inc'
  include 'api/user32.inc'
  include 'api/comdlg32.inc'
    


Help me with an advice, please.
Post 27 Jun 2012, 09:42
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 28 Jun 2012, 15:24
I would just subclass the default system dialog and stretch it a bit then add the child control.
Post 28 Jun 2012, 15:24
View user's profile Send private message Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek 28 Jun 2012, 20:53
Hey, typedef!

Thanks for your answer.

Can you give me any link to simple subclassing example, please? I could search myself, but I wouldn't be sure if I found the correct subclassing example.

It's a good idea, but I wonder why doesn't this simple stuff work, while it should? I found an example on Visual Basic, that works (I assume by screenshots, don't have a VB compiler), and also, if you look at OllyDbg open dialog, it's clearly seen, that "Arguments" control is custom template control. It inflicts terrible butthurt.
Post 28 Jun 2012, 20:53
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode 30 Jun 2012, 03:46
GetFileName etc, are deprecated. use COM instead. an intro:
http://weblogs.asp.net/kennykerr/archive/2006/11/10/Windows-Vista-for-Developers-_1320_-Part-6-_1320_-The-New-File-Dialogs.aspx
typedef wrote:
I would just subclass the default system dialog and stretch it a bit then add the child control.
No. dont waste your time with it.
samples using COM
http://msdn.microsoft.com/en-us/library/dd940376%28v=VS.85%29.aspx

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 30 Jun 2012, 03:46
View user's profile Send private message Visit poster's website Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek 30 Jun 2012, 07:56
hopcode
Thanks for the links. What about the compatibility? If one needs his program to work on 2000/XP also?
Post 30 Jun 2012, 07:56
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode 30 Jun 2012, 09:56
bzdashek wrote:
...compatibility win 2000/XP ?
if you dont need win2000, where the only solution available is a handmade template+hook, then the win7 SDK .NET 3.5 SP1 fits to XP too.
but a versioned solution for win2000 should be ok anyway, because IFileOpenDialog is not a function.
the question is who is so bold nowadays to use win2000 GUI to that customized extent ? Wink
ok, never presume. one more social link, porting from 501 to 600
http://social.msdn.microsoft.com/Forums/pl-PL/vcgeneral/thread/7feaa636-cf22-467c-830f-7b86aa14feec
Cheers,

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 30 Jun 2012, 09:56
View user's profile Send private message Visit poster's website Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek 30 Jun 2012, 19:55
hopcode wrote:

Cheers,

I see you point, hopcode Smile Thanks. I'll try to mess with COM interfaces, and develop a custom template for XP mode of the programme.
Post 30 Jun 2012, 19:55
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode 01 Jul 2012, 00:43
bzdashek wrote:
...mess with COM interfaces...

few little hints about COM so to avoid common problems.
- COM may be difficoult to debug.
- by defining interfaces follow the exact order of functions as in the header .h files of the SDK
- full comprehension of CoCreateInstance.
- be sure to ExitProcess and Release interfaces/instances of allocated objects.
- you may use IronFelix COM macros. they are good but they make the
code a bit opaque (my taste, because i dont use debug informations, and i rather like to write WYSIWYG now).
alternatively and simply,
- declare interfaces using struc as here http://code.google.com/p/x64lab/source/browse/develop/shared/shobjidl.inc
- and the macros here, http://code.google.com/p/x64lab/source/browse/develop/macro/com_macro.inc
- to have such simple access to COM interfaces, example of iFileOpenDialog
from http://code.google.com/p/x64lab/source/browse/develop/plugin/bk64/dialog.asm

hasta la vista, Smile

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 01 Jul 2012, 00:43
View user's profile Send private message Visit poster's website Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek 01 Jul 2012, 10:34
hopcode wrote:
bzdashek wrote:
...mess with COM interfaces...

few little hints about COM so to avoid common problems.
- COM may be difficoult to debug.
- by defining interfaces follow the exact order of functions as in the header .h files of the SDK
- full comprehension of CoCreateInstance.
- be sure to ExitProcess and Release interfaces/instances of allocated objects.
- you may use IronFelix COM macros. they are good but they make the
code a bit opaque (my taste, because i dont use debug informations, and i rather like to write WYSIWYG now).
alternatively and simply,
- declare interfaces using struc as here http://code.google.com/p/x64lab/source/browse/develop/shared/shobjidl.inc
- and the macros here, http://code.google.com/p/x64lab/source/browse/develop/macro/com_macro.inc
- to have such simple access to COM interfaces, example of iFileOpenDialog
from http://code.google.com/p/x64lab/source/browse/develop/plugin/bk64/dialog.asm

hasta la vista, Smile

That's whole bunch of information, thanks a lot, hopcode!

I've been actually searching for a good example on how to use IFileOpenDialog, you might have seen my thread couple of months ago, and now here it is. Thanks again.
Post 01 Jul 2012, 10:34
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.