Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-10-06
5
Medium Priority
?
239 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 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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 shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

886 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