Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Windows Desktop " Need to Mimic It " ?? Thought I did, But found out not :-(

Posted on 2004-10-06
5
Medium Priority
?
238 Views
Last Modified: 2010-04-05
Hello All;

  I am in the process of designing a program, that I had thought I was doing pretty good at, until I found out some information from the Delphi Newsgroup, and the person has not gotten back with me yet on any information on this.

  Here we go:

  In my Program, I am going to Mimic your "Windows Desktop"
Controls can be moved around on the Form, like they do on your Desktop.
{ This I had done in the development stages of the program }
But I was using: Form. Nothing else on it, and code that will allow the controls to move at run time.
BUT, I was informed when I ask about "Desktop like Buttons"
That they are not buttons, but that the "Windows Desktop" was infact a
ListView ??
OK, this has me totally stumped, and down... As I thought I was already mimicing the Desktop. But now I know that I am not.
A far cry from it.

   See in the program that I am designing, I want it to be like your
Windows OP. But of couse, relies on Windows to work :-)
Not even attempting to build a real OP. Not that good :-(

  But in the program. I need to mimic the Windows Desktop?

Can someone please let me know how this is done?
A link, some information from somewhere please?

I am also going to try to do a "Windows Explorer" that will only
Open up the Folder that the program is installed in,
And will not let the use Browse outside of the Program Folder.
But that is later.

Right now, I just need some information on the "Windows Desktop" Mimic.


( Question started with 20-points, will raise points for the best information given )

Take Care and Thank you All.
Wayne
0
Comment
Question by:Wayne Barron
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 11

Expert Comment

by:calinutz
ID: 12246127
If you want to "mimic" windows desktop what is the problem with not using a listview? Do you really have to build your mimic like microsoft did? What's the catch? If you did it using form and movable objects with properties that are similar to windows desktop objects then what is the big deal?
 I do not understand.
Of course it could be a listview with viewstyle=vsIcon. But who says that their way is the best way?

Do you have difficulties working with listview?
Youi know that you can assign data to the items of listview.... So your data may be the path of your desktop shortcut. You have caption of items, Assign to them images. Use for that a ImageList where you must append your icons at runtime.

It would be too much work to give you a full working code.
0
 
LVL 11

Expert Comment

by:calinutz
ID: 12246195
use this form as an example

object Form1: TForm1
  Left = 192
  Top = 107
  Width = 696
  Height = 480
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object ListView1: TListView
    Left = 0
    Top = 0
    Width = 688
    Height = 453
    Align = alClient
    Columns = <
      item
      end
      item
      end>
    IconOptions.Arrangement = iaLeft
    IconOptions.AutoArrange = True
    Items.Data = {
      380000000200000001000000FFFFFFFFFFFFFFFF000000000000000003313131
      02000000FFFFFFFFFFFFFFFF000000000000000003323232}
    LargeImages = ImageList1
    MultiSelect = True
    ShowWorkAreas = True
    SmallImages = ImageList1
    StateImages = ImageList1
    TabOrder = 0
  end
  object ImageList1: TImageList
    Left = 100
    Top = 52
  end
end



/// and add to the imagelist your icons and assign imageindex to your items
0
 
LVL 11

Expert Comment

by:calinutz
ID: 12246454
Or try this as an example:
//form

object Form1: TForm1
  Left = 192
  Top = 107
  Width = 696
  Height = 480
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object Image1: TImage
    Left = 8
    Top = 256
    Width = 225
    Height = 185
  end
  object ListView1: TListView
    Left = 0
    Top = 0
    Width = 688
    Height = 409
    Columns = <
      item
      end
      item
      end>
    IconOptions.Arrangement = iaLeft
    IconOptions.AutoArrange = True
    Items.Data = {
      380000000200000001000000FFFFFFFFFFFFFFFF000000000000000003313131
      02000000FFFFFFFFFFFFFFFF000000000000000003323232}
    LargeImages = ImageList1
    MultiSelect = True
    ShowWorkAreas = True
    SmallImages = ImageList1
    StateImages = ImageList1
    TabOrder = 0
  end
  object Button1: TButton
    Left = 268
    Top = 56
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 1
    OnClick = Button1Click
  end
  object ImageList1: TImageList
    Height = 32
    Width = 32
    Left = 180
    Top = 40
  end
  object OpenDialog1: TOpenDialog
    Left = 180
    Top = 124
  end
end
// and then code:
0
 
LVL 11

Accepted Solution

by:
calinutz earned 80 total points
ID: 12246459
// now code:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ImgList, ExtCtrls, StdCtrls, ShellApi;

type
  TForm1 = class(TForm)
    ListView1: TListView;
    ImageList1: TImageList;
    OpenDialog1: TOpenDialog;
    Button1: TButton;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  HI                : THandle;
  MyIconIndex       : word;
  IconItem    : TListItem;
  AttachFileName    : string;
  X                 : word;
  MAX_FILES_ATTACHED : integer;
begin
MAX_FILES_ATTACHED := 250;
  if ListView1.Items.Count>=MAX_FILES_ATTACHED then
  begin
     application.messagebox('New Item', 'Maximum number of items reached.', MB_ICONEXCLAMATION + MB_OK);
     exit;
  end;
  x := 0;
  if OpenDialog1.execute then
  begin
     AttachFileName := expandfilename(OpenDialog1.Filename);
     HI := ExtractAssociatedIcon(hInstance, pchar(AttachFileName), x);
     Image1.Picture.Icon.Handle := HI;
     MyIconIndex := ImageList1.addIcon(Image1.picture.icon);
     IconItem := ListView1.Items.Add;
     IconItem.caption := ExtractFileName(AttachFileName);
     IconItem.SubItems.add(AttachFileName);
     IconItem.imageindex := MyIconIndex;
   end;
 end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Image1.Visible:=False;
Listview1.LargeImages:=ImageList1;
Listview1.ViewStyle:=vsIcon;
end;

end.
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 12248106
Thank you [calinutz];

  For the information that you have provided here.

[Quote]Do you really have to build your mimic like microsoft did? What's the catch? If you did it using form and movable objects with properties that are similar to windows desktop objects then what is the big deal?
[/Quote]

  Honestly, I prefer the way that I have already started doing it.
And prefer to keep it as such, as it is something that I had been playing around with off and on for about 2 yrs.
  Wanting to find out how this is done, is really (Honestly) just for imformation. Maybe one day it may find a place in the project.
But right now, I like my way of doing it, It is easy and sweet.

==========
   I am going to award you the points, But with the code that you have provided.

  But could you please let me know, if there is a type of
Button (or) Label that will look like the Desktop items?
How you have the
Image <-- On Top
text Desc. <-- On Bottom ?

This way I can continue the path that I am currently on.
To see how it all works out?

  Thank You
Carrzkiss
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question