how to create a UI like Resource Editor?

Dear Gurus,
I want to create a UI which looks quite similar to that whe we open VC++ resource editor. Means on the left side are the resouces ina tree and on right pane new views gets added as and when we click on any resource on the left pane. I do not have any idea how to achieve that.

Can anyone guide me. any example fo this sort will be of great help.

Regards,

Nitin
[406 byte] By [qcnitin] at [2007-11-18 17:45:24]
# 1 Re: how to create a UI like Resource Editor?
I think that for the Visual Studio the left side is a dialog bar and the right side is actually just the rest of the client area. So probably a MDI application with a dialog bar is all you need.
Sam Hobbs at 2007-11-11 1:25:42 >
# 2 Re: how to create a UI like Resource Editor?
Dear Sam,
Thanks for your reply. Do you mean to say that with the help of a dialog bar only the kind of UI can be created.

Anyways I'll look into MSDN for dialog bar as i have nevr worked on that. Can you or anyone send me some information on dialog bar.

Regards,
Nitin
qcnitin at 2007-11-11 1:26:42 >
# 3 Re: how to create a UI like Resource Editor?
Search this forum for DialogBar and search the articles section
of dev-archive for CCoolDialogBar
souldog at 2007-11-11 1:27:49 >
# 4 Re: how to create a UI like Resource Editor?
Originally posted by qcnitin
Do you mean to say that with the help of a dialog bar only the kind of UI can be created.I think so but I am guessing.
Sam Hobbs at 2007-11-11 1:28:51 >
# 5 Re: how to create a UI like Resource Editor?
Dear gurus,
With your help, I am now able to create a dialog bar on the left-side as suggested by Sam Hobbs.. but can you tell me, in the Resource editor, when we create a new diaolg, then a blank dialog appears on the right-side..same for other resources..how does that happen..are they different views, or different child-frames..how can one make UI like that..how can i proceed so that say, when a user wnats to create a new dialog a different window appears than when he tries to create a menu or string table..

please help..

nitin
qcnitin at 2007-11-11 1:29:51 >
# 6 Re: how to create a UI like Resource Editor?
I might not understand what you are asking, but I think the answer is that you will of course have a button or menu item or whatever that the user uses to choose the various types. So in the handler for each type is where the appropriate window would be created. I am not sure if the windows correspond to separate documents; I assume not, but I also assume that there would be something in the document created for each new window. In other words, in the document, there would either be a new string, a new menu or a new dialog, or whatever.
Sam Hobbs at 2007-11-11 1:30:47 >
# 7 Re: how to create a UI like Resource Editor?
thanks Sam,
but i think i was not able to make you understand my problem..

Well, what i want to ask is that as in resource editor, when i try it Insert a Dialog, a blank dialog appears on right side of the main window..now, this dialog(blank dialog) is sticking on a window..i handle the process of creating this window with dialog in a mesaage handler in a menu item..but what i want is how this blank dialog appears on the window..how can i make a window containign a dialog, which sticks to the window..and is this window just a view or what??

same thing for menu creation..on a blank window a blank menu item appears..how does this happen..

am i able to make it clear a bit..plz reply..

nitin
qcnitin at 2007-11-11 1:31:56 >
# 8 Re: how to create a UI like Resource Editor?
I am not sure what you are asking. Are you asking how to create a dialog or how to make a window with a dialog in it? Or are you asking how to make it stick?
Sam Hobbs at 2007-11-11 1:32:56 >
# 9 Re: how to create a UI like Resource Editor?
HEllo Sam,
I want to know just how to create an User Interface, just like When we Click on Insert->Dialog in the Resource editor. I wan to know how to create the interface which appears on the right side of the window. with your help I am able to create the Dialog Bar on the left side. But on right side, I am unable to create the similar UI. Yes, i want to now, how can i make my dialog positioned at 0,0 of any window and how can i make it stick to the same window, so that when i move/resize the winodw, my dialog behaves in the same way. quite similar to what happens in the resource editor. a window contains a dialog, with the dialog sticking to it, moving with it etc. how can i do this.

sorry that I am unable to make it understood..

nitin
qcnitin at 2007-11-11 1:33:49 >
# 10 Re: how to create a UI like Resource Editor?
What you are trying to do is relatively advanced. You will learn a lot doing it.

One problem is that even if you are able to create a blank dialog, you will next need to add controls to it, right? If that is correct, then the solution for showing a blank dialog depends on how you will update it later.

Are you familiar with creating and showing dialogs normally? If not, then it will be difficult to explain how to do that in the advanced manners you need to for this project. Probably you will want to use "Create" to dynamically create the controls that get added to the dialog.

I think when you say "stick to the same window" you mean that you want the dialog to be a child of the window it is in (over).

Look at my Child Dialogs (http://simplesamples.info/MFC/ChildDialogs.php) page. It describes how to create a child dialog for normal use, but there will be differences for your project. However you can use that to understand some important things.

The host for my web site will be moving to a new server, so my web site might be unavailable for about an hour tonight.
Sam Hobbs at 2007-11-11 1:34:53 >
# 11 Re: how to create a UI like Resource Editor?
Dea Sam.
Thanks for your responses. I knnow how to create a modal/modeless dialogs. In my present project I am able to show a blank dialog and add few controls (Only CButton and CEdit) to it using "Create" function as said by you. But I am just creating a modeless dialog and thats it. I am not able to make it stick to any parent window(window on the right side).. I have also been able to move the controls and resize them, with help from some articles/codes form this site itself. But I am unable to make it look like as it looks in the resource editor. means, how to "Stick my dialog to the window and move it along when i move the window". I hope I am not worrying you. But I'll definitely look at the site link which you have given.

nitin
qcnitin at 2007-11-11 1:35:57 >
# 12 Re: how to create a UI like Resource Editor?
Maybe something like this will help you. (a minimal example)

p.s. the trick to make it stick is
1. Set the parent to the view
2. Handle OnNCHitTest
souldog at 2007-11-11 1:36:57 >
# 13 Re: how to create a UI like Resource Editor?
hi souldog,
thanks very much for your help. i really appreciate the help u guys show. thanks Sam Hobbs too..i think this will be fine with me for now..

Nitin
qcnitin at 2007-11-11 1:37:56 >
# 14 Re: how to create a UI like Resource Editor?
I'm getting a Crash when closing the App. (WinXP)

Assertion in:
BOOL PASCAL CWnd::WalkPreTranslateTree(HWND hWndStop, MSG* pMsg)

When you don't set the parent, it doesnt crash.

any ideas ?
wolamp at 2007-11-11 1:38:56 >
# 15 Re: how to create a UI like Resource Editor?
ok, a window cannot have WS_POPUP and WS_CHILD !!!

so you must change the style from WS_POPUP to WS_CHILD
first, and then set the parent.

StuckDialog_->ModifyStyle(WS_POPUP, WS_CHILD);
wolamp at 2007-11-11 1:40:02 >
# 16 Re: how to create a UI like Resource Editor?
Which statement asserted?
souldog at 2007-11-11 1:41:04 >
# 17 Re: how to create a UI like Resource Editor?
You can set the parent of a popup window, but you need to
be careful what you do.

Can you show me the code you were using?
souldog at 2007-11-11 1:41:58 >
# 18 Re: how to create a UI like Resource Editor?
Yah I was a bit sloppy on this.

The problem is not that the WS_CHILD flag needs to be set
and WS_POPUP turned off.

The problem is I was calling DestroyWindow in the destructor
of the view. OOPS

Should of handled

void CLIKERESOURCEEDITORView::OnDestroy()
{
CView::OnDestroy();
if(NULL != StuckDialog_->GetSafeHwnd())
{
StuckDialog_->DestroyWindow();
}


}
souldog at 2007-11-11 1:43:03 >
# 19 Re: how to create a UI like Resource Editor?
well, I used your zip code.
I build it in VC6 and also in VC7...get the same effect.

it makes an ASSERT in:

BOOL PASCAL CWnd::WalkPreTranslateTree(HWND hWndStop, MSG* pMsg)
{
ASSERT(hWndStop == NULL || ::IsWindow(hWndStop));

in wincore.cpp
wolamp at 2007-11-11 1:44:06 >
# 20 Re: how to create a UI like Resource Editor?
Let me know if it goes away if you move the call to DestroyWindow

hmm... It does not assert on my system..

Oh, by the way. I would set the WS_CHILD style is I were to
really do this.

Actually I would not use a dialog at all for that, I would
derive my own class from CWnd.
souldog at 2007-11-11 1:45:03 >
# 21 Re: how to create a UI like Resource Editor?
I think it must be:

if(StuckDialog_)
{
if(NULL != StuckDialog_->GetSafeHwnd())
{
StuckDialog_->DestroyWindow();
}
delete StuckDialog_;
}

otherwise you get a problem if the dialog wasn't opened !
--

but that didnt fix the crash !
wolamp at 2007-11-11 1:46:03 >
# 22 Re: how to create a UI like Resource Editor?
Just for your info here is GetSafeHwnd()

_AFXWIN_INLINE HWND CWnd::GetSafeHwnd() const
{ return this == NULL ? NULL : m_hWnd; }

from MSDN
CWnd::GetSafeHwnd
HWND GetSafeHwnd( ) const;

Return Value

Returns the window handle for a window. Returns NULL if the CWnd is not attached to a window or if it is used with a NULL CWnd pointer
souldog at 2007-11-11 1:47:05 >
# 23 Re: how to create a UI like Resource Editor?
And further

BOOL PASCAL CWnd::WalkPreTranslateTree(HWND hWndStop, MSG* pMsg)
{
ASSERT(hWndStop == NULL || ::IsWindow(hWndStop));

hWndStop is the result of a call to AfxGetMainWnd().

This all seems very fishy
souldog at 2007-11-11 1:48:10 >