Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

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

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
Wayne Barron
Asked:
Wayne Barron
  • 4
1 Solution
 
calinutzCommented:
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
 
calinutzCommented:
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
 
calinutzCommented:
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
 
calinutzCommented:
// 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
 
Wayne BarronAuthor, Web DeveloperAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now