Solved

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

Posted on 2004-10-06
5
233 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
  • 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 20 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 30

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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