Solved

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

Posted on 2004-10-06
5
230 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
// 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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
add combobox item based on numbers 9 96
code issue 8 84
Help on project with Soap 10 42
Convert a string into a TDateTime 5 44
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now