Winapi, Add Path dialog...

Started by
7 comments, last by phueppl1 23 years, 5 months ago
Hi there! following prob: I want to make an Add Path dialog... Just like in every install programm or whenever a programm requires a path from the user.. In the MSDN i found PathEdit Control , but since it''s not a class or something like that i have no idea how to use it... any help appeciated... thx, Phil
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )
Advertisement
anybody?
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )
I don''t have time to get the code right now (sorry). But try going to www.nullsoft.com and downloading their pimp installer w/ source adn search through that. Hope it helps.
(There''s also NSIS installer which comes w/ source, but I think it''s Delphi, or Pascal, or something)


"We are the music makers, and we are the dreamers of the dreams."
- Willy Wonka
Ähm.. sorry, but what does Nullsofts Winamp player got to do with WinAPI Editpath Dialogs...

;o)
cya,
Phil

Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states ;)
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )
nullsoft has more products than just winamp. They have another prog called "pimp installer", it''s an installation program, you write the script and it compiles an installation program for you. It comes with source. Sorry if I didn''t clarify. if you go to nullsoft.com it''ll have a "winamp" link, a "shoutcast" link, and a "more stuff" link, go to more stuff and at the top of the list is "nullsoft pimp installer". Later.


"We are the music makers, and we are the dreamers of the dreams."
- Willy Wonka
I went to the Page...

Nullsoft Pimp installer is a Programm to install the software you programmed...
I want to know, how to use/create a PathEdit control... It''s for our Leveleditor (to specify the Texturedirectories..)

cya,
Phil

Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states ;)
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )
Phil,

I think you''re missing the point. BitBlt means take a look at the source of the Pimp Installer and have a look at how they did it.

Happy coding

--
Russ
oh... ooops didn''t think of that....
Sorry BitBlt and Thx for the advice..
hope i can figure it out!
cya,
Phil
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )
What I was trying to say was that pimp installer comes with source code. But I got time now, so I''ll help you.

I assume you know how to make and handle dialog boxes. First make a text edit box on your dialog box. Let''s give it an ID of IDC_PATH. Now put a button next to it that says "browse" on it. Let its ID be IDC_BROWSE.

You also might wanna make a default directory variable at the beginning of your program, something like:
#define DEFAULTDIR "C:\\GAMES\\REALLY_COOL_GAME" 


Now in your Dialog Procudure, when you handle the WM_INITDIALOG message, you want to set the text to the default path with this:
SendDlgItemTxt(hwnd, IDC_PATH, DEFAULTDIR);  

This fills the edit box with the default directory.

Then you want to see if they hit the "browse" button to to install it where they want to. In your dialog Proc again, test for IDC_BROWSE, or whatever you called your browse button. Then put this:
BROWSEINFO bi;LPITEMIDLIST pidl;IMalloc *lpSHMalloc;bi.hwndOwner      = hWnd;bi.pidlRoot       = NULL;bi.pszDisplayName = szPath;bi.lpszTitle      = "Pick a folder to install the game"bi.ulFlags        = BIF_RETURNONLYFSDIRS;bi.lpfn           = NULL;bi.lParam         = 0;bi.iImage         = 0;pidl = SHBrowseForFolder(&bi);if (pidl){    SHGetPathFromIDList(pidl, Path);    SetDlgItemText(hWnd, IDC_PATH, Path);    SHGetMalloc(&lpSHMalloc);    if (lpSHMalloc)        {           lpSHMalloc->Free(pidl);           lpSHMalloc->Release();        }} 

In this case, Path is just a char array declared with the maximum length as the index. This will pop a little browse window up for you.

And then when you test for WM_COMMAND messages, and test for IDOK, or IDNEXT, whatever you call the button used to move on to the next installation step, you want to extract the directory they chose from the edit box. With this:
GetWindowText( GetDlgItem( hWnd,IDC_PATH ), TargetDir, sizeof( TargetDir )); 

TargetDir is just a char[] array of whatever you want the maximum length to be allowed. This extracts it and puts it in the TargetDir variable.

This is just a simple way to get one up. I sure hope this helps you.



"We are the music makers, and we are the dreamers of the dreams."
- Willy Wonka

This topic is closed to new replies.

Advertisement