An Icon/Dialog Question
Results 1 to 9 of 9

Thread: An Icon/Dialog Question

  1. #1
    Member
    Join Date
    Aug 2005
    Posts
    41

    An Icon/Dialog Question

    I have gotten forgetful, or I've been hacking in UNIX to much.
    I suppose it could be that I've been coding for about 27 straight hours.

    I have written a specialized port scanner (It looks for a pattern of services that look like they may be Windows 5.x Servers.). The program is nearly finished. It works, but I don't know how well yet.

    The program has been coded in raw C/Windows API. I was uncertain of the layout of the controls, so I used a dialog box as the main window.

    The problem is I've forgotten how to assign an icon to a dialog:

    * No Window Class to define it in.

    * I've tried various combinations of Window Styles.

    * I've called LoadIcon() from WinMain() and the Dialog Procedure.


    No matter what I try, I get the default icon. I've browsed my books and the web and can't find the answer. I know it possible, I've done it many times before.

    I believe this memory loss is what happens when one writes all their Windows applications in a RAD environment (Delphi) for to long.

    (Only 27kb file size & Under 1mb RAM, so far...)
    http://www.AntiOnline.com/sig.php?imageid=789\"A dark angel of sin, preying deep from within...\" - Rob Halford

  2. #2
    Banned
    Join Date
    Jul 2005
    Posts
    511
    Is the icon included in your resource file, that's part of your executable?

    Btw, although Delphi is a RAD tool, you can still use it to just write small executables by using the raw Windows API. If you don't use anything of the VCL, you can get applications as small as 30 KB. (Or less, if you use an older Delphi version.) In general, when you use the SysUtils unit in Delphi, the minimum size becomes between 40 and 60 KB.) If you ass the Classes unit then it will grow to over 100 KB. With the Forms unit in your sourcecode, they will be at least 250 to 300 KB in size, depending on your Delphi version. Adding the BDE-based database controls will soon get you near 1 MB or more of binary data.
    But if you just use the Windows unit you can keep the size quite small. I even managed to write a small database tool by using the ADO typelibrary tht stayed below 50 KB. (And I didn't use runtime packages.)

    I thought LoadIcon would work, though. Unless you don't have the icon in your resource in which case the LoadIcon call just returns NULL, resulting in the default icon. (No exception or other error message.) If LoadIcon returns NULL, use GetLastError (of course) to learn why it failed.

  3. #3
    Member
    Join Date
    Aug 2005
    Posts
    41
    Thanks.

    I was forgetting to SetIcon().

    I'm not picking on Delphi, I am just trying to ween myself off of it. When you want to set an icon in Delphi you can just click and pick.

    Using Delphi has made me forgetful about the way the system actually works behind the VCL.
    http://www.AntiOnline.com/sig.php?imageid=789\"A dark angel of sin, preying deep from within...\" - Rob Halford

  4. #4
    Banned
    Join Date
    Jul 2005
    Posts
    511
    I know you're not picking on Delphi. I'm just not sure if you knew you can use Delphi without the VCL too. The RAD functionality is just to make things easier.

  5. #5
    Member
    Join Date
    Aug 2005
    Posts
    41
    You mean something like,

    Code:
    procedure OpenNotepad;
    
    var
      StartInfo : STARTUPINFO;
      ProcessReturnInfo : PROCESS_INFORMATION;
    
    begin
      StartInfo.cb := sizeof(STARTUPINFO);
      StartInfo.lpReserved := nil;
      StartInfo.lpDesktop := nil;
      StartInfo.lpTitle := PChar('');
      StartInfo.dwFlags := STARTF_USESTDHANDLES;
      StartInfo.cbReserved2 := 0;
      StartInfo.lpReserved2 := nil;
      StartInfo.hStdInput := 0;
      StartInfo.hStdOutput := 0;
      StartInfo.hStdError := 0;
      
      CreateProcess(nil,
                    PChar('NOTEPAD.EXE'),
                    nil,
                    nil,
                    FALSE,
                    NORMAL_PRIORITY_CLASS,
                    nil,
                    nil,
                    StartInfo,
                    ProcessReturnInfo);
    end;
    yeah I know. Just playing around... (Read mood)

    Actually, at one time programmed with Win16 and the ObjectWindows Library. (Borland Pascal 7, early 90s)
    http://www.AntiOnline.com/sig.php?imageid=789\"A dark angel of sin, preying deep from within...\" - Rob Halford

  6. #6
    Banned
    Join Date
    Jul 2005
    Posts
    511
    Yeah, exactly what I meant, although you can do lot of other things too if you're not afraid to just use the raw Windows API. There used to be some alternative library for Delphi (I think KOL) that could be used to write very small executables in Delphi. It had a lot of functionality in it too. A lot less bloated than the VCL, at least.

  7. #7
    Member
    Join Date
    Aug 2005
    Posts
    41
    I now have a mild hangover and I noticed I forgot to ZeroMemory() in the above procedure.

    I've never heard of KOL. Could it be used within the IDE? (I'm not sure you'll get what I mean.)

    Years ago, as an experiment, I made a complete text editor with nothing but pure Win32. The binary was something like 6k smaller than the MSVC 6 version of the same program.
    http://www.AntiOnline.com/sig.php?imageid=789\"A dark angel of sin, preying deep from within...\" - Rob Halford

  8. #8
    Banned
    Join Date
    Jul 2005
    Posts
    511
    KOL = Key Objects Library. The Delphi IDE can use it just like it can use a console application. You'll be missing the graphical form designers. Information about it can be found at http://bonanzas.rinet.ru/ in case you're interested. It's been a while since I've checked KOL out, btw. Just found it again with Google. Apparantly they added MCK (Mirror Classes Kit) to add some visual programming support to this library. And it still generates applications that are a lot smaller than the average Delphi applications. A lot less overhead. It's Delphi without the RAD.

  9. #9
    Member
    Join Date
    Aug 2005
    Posts
    41
    I downloaded KOL. I haven't had a chance to mess with it yet. It looks like KOL gonna take some reading.

    The only 3rd party packages I've messed with are SynEdit & JVCL. I haven't really used much of the JVCL, but I love SynEdit (Makes making a good editor easy).

    I can't believe you've memorized the required units in Delphi.
    I'm the same way, but with linking MSC libraries. In Delphi, I just take what it gives me.
    I should look into taking things out, a lot of my code is in raw API anyway. (Whatever I don't know how to do with the VCL.)

    I been reading some posts here, whats with all the quick draw flamer types? If I see a small indiscretion, I ignore it. A lot these folks are all over one another, about nothing.
    http://www.AntiOnline.com/sig.php?imageid=789\"A dark angel of sin, preying deep from within...\" - Rob Halford

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •