BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TOpenPictureDialog in thumbnail view?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics)
View previous topic :: View next topic  
Author Message
teroni
Guest





PostPosted: Sun Jan 02, 2005 4:10 am    Post subject: TOpenPictureDialog in thumbnail view? Reply with quote




I have seen some delphi code for sending a message to an open picture dialog that allows viewing of files in thumbnail view. It only works for win xp. I have attempted to convert the code to c++ but have failed. If you know how to do this in c++, I would love to hear from you.

teroni

Here is the delphi code, just in case it might help:

private
{ Private declarations }
procedure WMUser(var msg: TMessage); message WM_USER;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}


const
FCIDM_SHVIEW_LARGEICON = 28713;
FCIDM_SHVIEW_SMALLICON = 28714;
FCIDM_SHVIEW_LIST = 28715;
FCIDM_SHVIEW_REPORT = 28716;
FCIDM_SHVIEW_THUMBNAIL = 28717; // XP only
FCIDM_SHVIEW_TILE = 28718; // XP

procedure TForm1.WMUser(var msg: TMessage);
var
Dlg: HWND;
Ctrl: HWND;
begin
Dlg := msg.WParam;
Ctrl := FindWindowEx(Dlg, 0, PChar('SHELLDLL_DefView'), nil);
if Ctrl <> 0 then
begin
SendMessage(Ctrl, WM_COMMAND, FCIDM_SHVIEW_THUMBNAIL, 0 )
end;
end;

procedure TForm1.OpenDialog1Show(Sender: TObject);
var
Dlg: HWND;
begin
Dlg := GetParent((Sender as TOpenDialog).Handle);
PostMessage(Handle, WM_USER, Dlg, 0);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
end;
end;

Back to top
Lapo Guidi
Guest





PostPosted: Fri Jan 14, 2005 1:22 am    Post subject: Re: TOpenPictureDialog in thumbnail view? Reply with quote



Hi, I tried and I wrote this code that seems to work.
Hope it can help you.

Bye
Lapo

// START OF CODE

// Unit1.h
//--------------------------------------------------------------------------
-
#ifndef Unit1H
#define Unit1H
//--------------------------------------------------------------------------
-
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Dialogs.hpp>
//--------------------------------------------------------------------------
-
#define FCIDM_SHVIEW_LARGEICON 28713
#define FCIDM_SHVIEW_SMALLICON 28714
#define FCIDM_SHVIEW_LIST 28715
#define FCIDM_SHVIEW_REPORT 28716
#define FCIDM_SHVIEW_THUMBNAIL 28717
#define FCIDM_SHVIEW_TILE 28718
//--------------------------------------------------------------------------
-
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TOpenDialog *OpenDialog;
void __fastcall Button1Click(TObject *Sender);
void __fastcall OpenDialogShow(TObject *Sender);
void __fastcall WMUser(TMessage &msg);
private: // User declarations
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_USER+1, TMessage, WMUser);
END_MESSAGE_MAP(TForm);
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//--------------------------------------------------------------------------
-
extern PACKAGE TForm1 *Form1;
//--------------------------------------------------------------------------
-
#endif


// Unit.cpp
//--------------------------------------------------------------------------
-
#include <vcl.h>
#pragma hdrstop
//--------------------------------------------------------------------------
-
#include "Unit1.h"
//--------------------------------------------------------------------------
-
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------------------
-
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::Button1Click(TObject *Sender)
{
OpenDialog->Execute();
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::WMUser(TMessage &msg)
{
HWND Ctrl;
Ctrl=FindWindowEx((void *)msg.WParam, 0, "SHELLDLL_DefView", NULL);
if(Ctrl!=NULL)
SendMessage(Ctrl, WM_COMMAND, FCIDM_SHVIEW_THUMBNAIL, 0);
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::OpenDialogShow(TObject *Sender)
{
PostMessage(Handle, WM_USER+1, (unsigned)GetParent(((TOpenDialog
*)(Sender))->Handle), 0);
}
//--------------------------------------------------------------------------
-

END OF CODE


Back to top
Patrick
Guest





PostPosted: Sat Mar 19, 2005 7:16 pm    Post subject: Re: TOpenPictureDialog in thumbnail view? Reply with quote



Here is another way - Put this code in the OnFolderChange event of the(any)
file dialog.

//---------------------------------------------------------------------------
void __fastcall TFFForm::ThumbView(TObject *Sender) {
TCommonDialog *FileDialog = dynamic_cast<TCommonDialog *>(Sender); //
Who Asked?
HWND const hView = FindWindowEx(
GetParent(FileDialog->Handle), NULL, "SHELLDLL_DefView",
NULL );
SNDMSG(hView, WM_COMMAND, 28717, 0); // Change Sender to
Thumbs View
}
--
Regards, Patrick Leabo [email]pleabo (AT) comcast (DOT) net[/email]

"Lapo Guidi" <lapoguidi (AT) inwind (DOT) it> wrote

Quote:
Hi, I tried and I wrote this code that seems to work.
Hope it can help you.

Bye
Lapo

// START OF CODE

// Unit1.h
//--------------------------------------------------------------------------
-
#ifndef Unit1H
#define Unit1H
//--------------------------------------------------------------------------
-
#include <Classes.hpp
#include #include #include #include //--------------------------------------------------------------------------
-
#define FCIDM_SHVIEW_LARGEICON 28713
#define FCIDM_SHVIEW_SMALLICON 28714
#define FCIDM_SHVIEW_LIST 28715
#define FCIDM_SHVIEW_REPORT 28716
#define FCIDM_SHVIEW_THUMBNAIL 28717
#define FCIDM_SHVIEW_TILE 28718
//--------------------------------------------------------------------------
-
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TOpenDialog *OpenDialog;
void __fastcall Button1Click(TObject *Sender);
void __fastcall OpenDialogShow(TObject *Sender);
void __fastcall WMUser(TMessage &msg);
private: // User declarations
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_USER+1, TMessage, WMUser);
END_MESSAGE_MAP(TForm);
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//--------------------------------------------------------------------------
-
extern PACKAGE TForm1 *Form1;
//--------------------------------------------------------------------------
-
#endif


// Unit.cpp
//--------------------------------------------------------------------------
-
#include #pragma hdrstop
//--------------------------------------------------------------------------
-
#include "Unit1.h"
//--------------------------------------------------------------------------
-
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------------------
-
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::Button1Click(TObject *Sender)
{
OpenDialog->Execute();
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::WMUser(TMessage &msg)
{
HWND Ctrl;
Ctrl=FindWindowEx((void *)msg.WParam, 0, "SHELLDLL_DefView", NULL);
if(Ctrl!=NULL)
SendMessage(Ctrl, WM_COMMAND, FCIDM_SHVIEW_THUMBNAIL, 0);
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::OpenDialogShow(TObject *Sender)
{
PostMessage(Handle, WM_USER+1, (unsigned)GetParent(((TOpenDialog
*)(Sender))->Handle), 0);
}
//--------------------------------------------------------------------------
-

END OF CODE





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.