Author Topic: Common Item Dialog  (Read 130 times)

Jokaste

  • Regular Member
  • *
  • Posts: 19
  • Never be pleased, always improve
    • Grincheux's Tools
Common Item Dialog
« on: November 14, 2017, 04:54:28 AM »

How to use Common Item Dialog with the assembler. I don't how to use that kind of interface. So I need you.
https://msdn.microsoft.com/en-us/library/windows/desktop/bb776913(v=vs.85).aspx
Kenavo
---------------------------
Grincheux / Jokaste

Mikl__

  • Member
  • ****
  • Posts: 549
Re: Common Item Dialog
« Reply #1 on: November 14, 2017, 05:27:46 AM »
Hi, Jokaste!
and why this ridiculous font of a giant size? To get the answer faster?

Jokaste

  • Regular Member
  • *
  • Posts: 19
  • Never be pleased, always improve
    • Grincheux's Tools
Re: Common Item Dialog
« Reply #2 on: November 14, 2017, 05:32:34 AM »
No but I have problem with font size and new lines. I hope an answer but this is not the reason of the BIG font.
Kenavo
---------------------------
Grincheux / Jokaste

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4873
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Common Item Dialog
« Reply #3 on: November 14, 2017, 06:19:19 AM »
From a quick look at the link, these look like a COM interface.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

Jokaste

  • Regular Member
  • *
  • Posts: 19
  • Never be pleased, always improve
    • Grincheux's Tools
Re: Common Item Dialog
« Reply #4 on: November 14, 2017, 01:40:29 PM »
 :badgrin:
Kenavo
---------------------------
Grincheux / Jokaste

aw27

  • Member
  • ****
  • Posts: 783
Re: Common Item Dialog
« Reply #5 on: November 14, 2017, 03:30:31 PM »
:badgrin:
Is your difficulty circumscribed to:
1- COM in general?
2- COM in Assembly Language?
3- Common Item Dialogs?

I suspect that it is either 1 or 2, because 3 is trivial.
For 1, you are not really in the right place to ask. For 2 there are many resources in this site, namely in relationship with DirectX (you have to search yourself, because i am lazy by design).

mabdelouahab

  • Member
  • ***
  • Posts: 339
Re: Common Item Dialog
« Reply #6 on: November 14, 2017, 06:22:14 PM »
A very simple example:

Code: [Select]
  include IfileOpenDX64.Inc

  .data
  c_rgSaveTypes dq __ustr("Text Document") ,__ustr("*.txt")  ,\
  __ustr("Word Document") ,__ustr("*.dox")  ,\   
  __ustr("Executable") ,__ustr("*.exe")  ,\   
  __ustr("All File") ,__ustr("*.*")   
  .code


Main proc
call BasicFileOpen
    invoke ExitProcess,0
Main endp
BasicFileOpen proc
LOCAL FileOpenDialog:QWORD
LOCAL ShellItem:QWORD
LOCAL dwFlags:QWORD
LOCAL hwnd:QWORD
LOCAL fname:QWORD

        invoke  CoInitialize,0
        .if rax
        invoke  MessageBoxA,0," CoInitialize failed.",0,0
        ret
        .endif
        invoke  CoCreateInstance,addr CLSID_FileOpenDialog,0,CLSCTX_INPROC_SERVER,addr IID_IFileOpenDialog,addr FileOpenDialog
        .if rax
        invoke  MessageBoxA,0," CoCreateInstance failed.",0,0
        ret
        .endif
mov r10,FileOpenDialog
mov r10,[r10]
invoke [r10].IFileOpenDialog.GetOptions,FileOpenDialog,addr dwFlags
        .if rax
        invoke  MessageBoxA,0," IFileOpenDialog.GetOptions failed.",0,0
        ret
        .endif

        or      dwFlags,FOS_FORCEFILESYSTEM
mov r10,FileOpenDialog
mov r10,[r10]
invoke [r10].IFileOpenDialog.SetOptions,FileOpenDialog,dwFlags
        .if rax
        invoke  MessageBoxA,0," IFileOpenDialog.SetOptions failed.",0,0
        ret
        .endif
mov r10,FileOpenDialog
mov r10,[r10]
invoke [r10].IFileOpenDialog.SetFileTypes,FileOpenDialog,4,addr c_rgSaveTypes
        .if rax
        invoke  MessageBoxA,0," IFileOpenDialog.SetFileTypes failed.",0,0
        ret
        .endif
mov r10,FileOpenDialog
mov r10,[r10]
invoke [r10].IFileOpenDialog.Show,FileOpenDialog,hwnd
mov r10,FileOpenDialog
mov r10,[r10]
invoke [r10].IFileOpenDialog.GetResult,FileOpenDialog,addr ShellItem
        .if rax
        invoke  MessageBoxA,0," IFileOpenDialog.GetResult failed.",0,0
        ret
        .endif

  mov r10,ShellItem
mov r10,[r10]
invoke [r10].IShellItem.GetDisplayName,ShellItem,SIGDN_FILESYSPATH,addr fname
         
        invoke  MessageBoxW,0,fname,__ustr("DisplayName"),0

mov r10,FileOpenDialog
mov r10,[r10]
invoke [r10].IFileOpenDialog.Release,FileOpenDialog
  mov r10,ShellItem
mov r10,[r10]
invoke [r10].IShellItem.Release,ShellItem
        ret

BasicFileOpen endp


end


IfileOpenDX64.Inc:
Code: [Select]
option frame:auto
OPTION LITERALS:ON
  OPTION DOTNAME                         


__includelib macro lib_:VARARG
FOR lib__,<lib_>
INCLUDELIB \masm32\lib64\&lib__&.LIB
endm
endm
__impProc macro proc_:VARARG
FOR proc__,<proc_>
proc__ proto :vararg
endm
endm


__includelib kernel32,user32,msvcrt, oleaut32, ole32
__impProc ExitProcess,\
MessageBoxA,\
MessageBoxW,\
printf,\
CoInitialize,\
CoCreateInstance
    _pMtd  TYPEDEF PROTO :VARARG
    MTD  TYPEDEF PTR _pMtd
GUID    STRUCT
    Data1   dd ?
    Data2   dw ?
    Data3   dw ?
    Data4   db 8 dup(?)
GUID ENDS
; S_OK equ 0
CLSCTX_INPROC_SERVER        equ 1
FOS_FORCEFILESYSTEM equ 040h
SIGDN_FILESYSPATH equ 080058000h

.DATA

  CLSID_FileOpenDialog GUID <0DC1C5A9Ch,0E88Ah,04ddeh,<0A5h,0A1h,060h,0F8h,02Ah,020h,0AEh,0F7h>>
IID_IFileSaveDialog GUID <084bccd23h,05fdeh,04cdbh,<0aeh,0a4h,0afh,064h,0b8h,03dh,078h,0abh>>
IID_IFileOpenDialog GUID <0d57c7288h,0d4adh,04768h,<0beh,002h,09dh,096h,095h,032h,0d9h,060h>>
IID_IFileDialogEvents GUID <0973510dbh,07d7fh,0452bh,<089h,075h,074h,0a8h,058h,028h,0d3h,054h>>
IID_IShellItem GUID <043826d1eh,0e718h,042eeh,<0bch,055h,0a1h,0e2h,061h,0c3h,07bh,0feh>>

IFileSaveDialog struct
QueryInterface MTD ?
AddRef MTD ?
Release MTD ?
Show MTD ?
SetFileTypes MTD ?
SetFileTypeIndex MTD ?
GetFileTypeIndex MTD ?
Advise MTD ?
Unadvise MTD ?
SetOptions MTD ?
GetOptions MTD ?
SetDefaultFolder MTD ?
SetFolder MTD ?
GetFolder MTD ?
GetCurrentSelection MTD ?
SetFileName MTD ?
GetFileName MTD ?
SetTitle MTD ?
SetOkButtonLabel MTD ?
SetFileNameLabel MTD ?
GetResult MTD ?
AddPlace MTD ?
SetDefaultExtension MTD ?
Close MTD ?
SetClientGuid MTD ?
ClearClientData MTD ?
SetFilter MTD ?
SetSaveAsItem MTD ?
SetProperties MTD ?
SetCollectedProperties MTD ?
GetProperties MTD ?
ApplyProperties MTD ?
IFileSaveDialog ends
IFileOpenDialog struct
QueryInterface MTD ?
AddRef MTD ?
Release MTD ?
Show MTD ?
SetFileTypes MTD ?
SetFileTypeIndex MTD ?
GetFileTypeIndex MTD ?
Advise MTD ?
Unadvise MTD ?
SetOptions MTD ?
GetOptions MTD ?
SetDefaultFolder MTD ?
SetFolder MTD ?
GetFolder MTD ?
GetCurrentSelection MTD ?
SetFileName MTD ?
GetFileName MTD ?
SetTitle MTD ?
SetOkButtonLabel MTD ?
SetFileNameLabel MTD ?
GetResult MTD ?
AddPlace MTD ?
SetDefaultExtension MTD ?
Close MTD ?
SetClientGuid MTD ?
ClearClientData MTD ?
SetFilter MTD ?
GetResults MTD ?
GetSelectedItems MTD ?
IFileOpenDialog ends
IFileDialogEvents struct
QueryInterface MTD ?
AddRef MTD ?
Release MTD ?
OnFileOk MTD ?
OnFolderChanging MTD ?
OnFolderChange MTD ?
OnSelectionChange MTD ?
OnShareViolation MTD ?
OnTypeChange MTD ?
OnOverwrite MTD ?
IFileDialogEvents ends
IShellItem struct
QueryInterface MTD ?
AddRef MTD ?
Release MTD ?
BindToHandler MTD ?
GetParent MTD ?
GetDisplayName MTD ?
GetAttributes MTD ?
Compare MTD ?
IShellItem ends
__ustr MACRO qstr:vararg
LOCAL arg,qot,q,bstrLbl,bstr_Seg,FrstL,tmpLen,cur_Pos,tmpStr,cur_tPos

cs_Seg catstr @CurSeg
    ifidn cs_Seg, <CONST>
bstr_Seg TEXTEQU <.const>        
    elseifidn cs_Seg, <_BSS>
bstr_Seg TEXTEQU <.data?>
    elseifidn cs_Seg, <_DATA>
bstr_Seg TEXTEQU <.data> 
    elseifidn cs_Seg, <_TEXT>
bstr_Seg TEXTEQU <.code>         
    endif
.data
FrstL = 0
FOR arg,<qstr>
tmpStr equ <>
qot SubStr <arg>,1,1
IsQot = 0
IFIDNI qot,<!'>
IsQot = 1
ELSEIFIDNI qot,<!">
IsQot = 1
ENDIF
IF IsQot eq 1
tmpLen = @SizeStr(<arg>)
tmpLen = tmpLen - 2
cur_Pos = 1
cur_tPos = 0
QuotF = 0
repeat tmpLen
cur_Pos=cur_Pos+1
cur_tPos=cur_tPos+1
ch_unq SubStr <arg>,cur_Pos,1
tmpStr2 CATSTR <>
IFIDNI ch_unq,<!">
IF QuotF eq 0
QuotF = 1
ELSE
QuotF = 0
tmpStr2 CATSTR <!022h>
ENDIF
ELSE
tmpStr2 CATSTR <!">,ch_unq,<!">
ENDIF
IF QuotF eq 0
IF (cur_Pos eq 2)
tmpStr CATSTR tmpStr,tmpStr2
ELSE
IF (cur_tPos eq 1)
tmpStr CATSTR tmpStr,tmpStr2
ELSE
tmpStr CATSTR tmpStr,<!,>,tmpStr2
ENDIF
ENDIF
ENDIF
IF cur_tPos eq 15
IF FrstL eq 0
bstrLbl dw tmpStr
FrstL = 1
ELSE
dw tmpStr
ENDIF
cur_tPos = 0
tmpStr CATSTR <>
ENDIF
endm
IF tmpLen ne 0
IF cur_tPos ne 0
IF FrstL eq 0
bstrLbl dw tmpStr
FrstL = 1
ELSE
dw tmpStr
ENDIF
ENDIF
ENDIF
ELSE
IF FrstL eq 0
bstrLbl dw arg
FrstL = 1
ELSE
dw arg
ENDIF
ENDIF
ENDM
IF FrstL eq 0
bstrLbl dw 0
ELSE
dw 0
ENDIF
bstr_Seg
EXITM <OFFSET bstrLbl>
ENDM


Jokaste

  • Regular Member
  • *
  • Posts: 19
  • Never be pleased, always improve
    • Grincheux's Tools
Re: Common Item Dialog
« Reply #7 on: November 14, 2017, 08:13:53 PM »
Thanks mabdelouahab that's what I was looking for. :greenclp: :eusa_boohoo:
[/size]For AW67, the answer is simple YES for the three points! :eusa_naughty:
Kenavo
---------------------------
Grincheux / Jokaste

aw27

  • Member
  • ****
  • Posts: 783
Re: Common Item Dialog
« Reply #8 on: November 15, 2017, 01:36:43 AM »
Thanks mabdelouahab that's what I was looking for. :greenclp: :eusa_boohoo:
[/size]For AW67, the answer is simple YES for the three points! :eusa_naughty:

OK, Jokasper  :t