-
GUI help
I'm almost totally new to gui programming, especially with mfc, which I now use.
Therefor I wonder how hard something like this is to do something like this: http://warblastcrew.ebw.ca/tmp/timeline.jpg I've just copied and pasted from a lot of programs, bu I want my program to look something like that.
Now, can anyone tell me what I should thing about when trying to create this gui? For example how's the best way to do a userdrawn listbox in a tabcontrol?
Is there any good sites, tutorials or any other help?
And finally: How hard is gui creating in mfc, compaired to, hmm..., for example java with swing classes?
Since I'm a real ewbe to mfc gui, please tell anything you think is relevant!
(I know that was a really broad question, but I've got to learn it somehow... ;) )
-
Well I don't think it'd be anywhere NEAR easy to create that... incredibly hard. Even for someone like me who's been doing WinAPI for a while now.
Well, actually it wouldn't be too tough (except I can't figure out how to put on a slideabar :rolleyes: or tab-list...stupid petzold's not having a big chapter on common controls!)
You might want to pick up a book on MFC...I don't know any because I use true API, but I'm sure someone here could refer you to one...
Lotta help I am :) heh, and if you're coming from Java or VB you're in for a real shocker when you start trying to create that ;)
-
As I said, every reply makes me happy! ;)
Well. I've just done some java and also soma vb, but most of my life i've been using c++, just not gui-prgramming, except for c++ builder, which makes it rather simple, but I don't like to use it.
Isn't there any program which can be used to design the gui and then generate code for mfc?
First of all: Should the controls be created in the creation of the main frame or the client area? Main frame, right?
-
Its not something I would want to start with but it can be done.
You will need to go beyond the basics to get the display right. (into HDC's, TAB and owner draw ctrls)
I would use the resource editor in the compiler. My prefrence is for MSVC. It will also write / hide some of the code from you.
The easiest way to do the TAB ctrl is to create small dialogs and paste them on top of the TAB sheets.
The main display is a 'static' or 'frame' with a HDC drawn over it.
-
... so you mean that I should more or less give it up? :)
-
No, never ever give up. If you want to do something, you have to go for it. But do it all in pieces. say now: I'm going to learn the toolbar, now the slider (Ive no idea how this damn thing work,but looks like I'm not the only one :D)
It will probably take you a while before you can do something like this. But if you like programing for the GUI, then you'll have fun and learn a lot.
I always go to planet source . you can download some source and see how they do stuff.
-
As Maes said
'Never give up' or in. (unless that will get you what you need)
for sliders, in the callback use (for horizontal sliders)
This will find the position and call for a redraw of the slider after the user has changed the position of the thumb tack.
Code:
case WM_HSCROLL:
hSlider=GetDlgItem(hwnd ,IDC_SLIDER );
nPos=SendMessage(hSlider ,TBM_GETPOS ,0 ,0 );
if(nPos!=LastHorzPos)//changed scroll position
{
SendMessage(hSlider ,TBM_SETPOS ,(WPARAM)TRUE ,(LPARAM)nPos );
LastHorzPos=nPos;
UpdateWindow(hwnd);
}
break;
-
The thing I think I'll have most problem with is that tabcontrol which includes a custom drawn listbox. I can start with just a listbox, but how do I conbine controls? That's my biggest issue which I haven't understood right now...
-
Leave the TAB out for now.
Later add it in. Then as the user changes the TAB switches you will get a message in the callback as to which is showing. If it is the one for the list box display it on screen
Code:
//then set its position on top of the TAB ctrl
GetClientRect( GetDlgItem( hwnd, IDC_TAB_CTRL) ,&ClientRect);
SetWindowPos(GetDlgItem( hwnd, IDC_LISTBOX), HWND_TOP,
ClientRect.left, ClientRect.top, ClientRect.right-ClientRect.left, ClientRect.bottom-ClientRect.top,
SWP_SHOWWINDOW);
UpdateWindow( GetDlgItem( hwnd, IDC_LISTBOX));//call a paint
if not just hide it till you need it again
ShowWindow( GetDlgItem( hwnd, IDC_LISTBOX), SW_HIDE);