|
I want to use a couple of child windows in my SDI application (with caption, min and max boxes, etc...(eg. WS_OVERLAPPEDWINDOW). They are children of CView. When I create them in response to CView's WM_CREATE, the children are not shown. But when I regster a class for my children, the are shown. Why is like that?
But the real problem is that those windows don't have a focus (even when a caption bar is clicked they still have inactive caption!!). Pressing a key generates WM_KEYDOWN for CView not for the child window.
Another problem: If I create a button in the child window and click it, the button has all the time focus, even when other child window are clicked. I cannot find any example of how to create child windows in a main window. I have over 40 books on VC++ but none of those explain this.
Thank you any suggestions
(The same problem occurs when children are created in SDI without Doc/View support).
Jerzy
|
|
|
|
|
One of my visual c++ books tells me that in order to control the showing and hiding of toolbars, create the View menu item with the same ID as the toolbar resource, and map the ON_COMMAND_EX to OnBarCheck and the update UI to OnUpdateControlBarMenu. This compiles, but it isn't doing a damn thing - the menu items aren't checked and selecting them does nothing. Has anyone else gotten this to work?
thanks,
Jake
|
|
|
|
|
Works fine for me, maybe you could post the code in question so we can take a look at it.
cheers,
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
I'm trying to get this message map code in my CMainFrame class to control showing/hiding my toolbars. I know the menu IDs are correct, because I changed the message map as a test to map to some functions I wrote, and they worked. This, however, isn't doing anything.
ON_COMMAND_EX(IDR_TOOLBAR1, OnBarCheck)
ON_COMMAND_EX(IDR_TOOLBAR2, OnBarCheck)
ON_UPDATE_COMMAND_UI(IDR_TOOLBAR1, OnUpdateControlBarMenu)
ON_UPDATE_COMMAND_UI(IDR_TOOLBAR2, OnUpdateControlBarMenu)
This is the only code related to this - do I need anything else? Is there a problem with the CMainFrame class handling this? Ideas?
thanks,
Jake
|
|
|
|
|
These are fine
ON_COMMAND_EX ( IDR_TOOLBAR1, OnBarCheck )<br />
ON_COMMAND_EX ( IDR_TOOLBAR2, OnBarCheck )
This wont work the way you expect it too. This is because your OnUpdateControlBarMenu() handler has no way of differentiating between the two toolbars.
ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR1, OnUpdateControlBarMenu )<br />
ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR2, OnUpdateControlBarMenu )
You'll need to use two functions to get the desired effect.
ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR1, OnUpdateToolBar1 )<br />
ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR2, OnUpdateToolBar2 )
-or-
You could use the ON_UPDATE_COMMAND_UI_RANGE macro.
void CMainFrame::OnBarCheck ( UINT nID ) {
switch ( nID ) {
case IDR_TOOLBAR1:
ShowControlBar ( &m_wndToolBar1, !m_wndToolBar1.IsVisible (), FALSE );
break;
case IDR_TOOLBAR2:
ShowControlBar ( &m_wndToolBar2, !m_wndToolBar2.IsVisible (), FALSE );
break;
default:
break;
}
RecalcLayout ();
}
void CMainFrame::OnUpdateToolBar1 ( CCmdUI * pCmdUI ) {
pCmdUI->SetCheck ( m_wndToolBar1.IsVisible () );
}
void CMainFrame::OnUpdateToolBar2 ( CCmdUI * pCmdUI ) {
pCmdUI->SetCheck ( m_wndToolBar2.IsVisible () );
}
That should get it working for you.
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Thanks a lot for your help. It's finally working.
Jake
|
|
|
|
|
Does anyone know of a Windows Common dialog, or standardized way to display the user accounts on a Windows NT machine, so that a user can select permissions and such?
|
|
|
|
|
There is a standardized way to display this information, its called the User Manager. Do you really want to expose this to ordinary users? I would leave it up the administrator to assign rights and permissions.
|
|
|
|
|
In the registration process of this program Im working on, I would like to have it a dialog box where I (the administrator) can enter the username and password that the server will run under (yes I could do this in dcomcnfg, but I would like to put that functionality in my program as well). And while the user manager is a good way to display this information, I cannot get data selected from the user manager into my project, which is what I want. The "Browse for user" dialog box presented in dcomcnfg is the same dialog that is presented when you set the permissions on a file or folder, which is why I thought it might be a standard dialog box...That is that dialog box I would like to put up, and if theres a standard way to do it that would be best =)
|
|
|
|
|
Use Net* and Lsa* functions. For example NetUserEnum, NetUserChangePassword, LsaEnumerateAccountRights ... and many many other.;)
|
|
|
|
|
Sweet thanks...the Net* functions answer most of my question. Do you know if there is a way to bring up that seemingly standard "Add Users/Groups" dialog, with the combo box at the top, and the list box to display the users/groups? Ive seen the identical dialog box both in windows, and on separate applications, so I assume its standard in some way...
Thanks again
|
|
|
|
|
I have a sdi formview based app, and when the main form resizes, I want my listbox (which takes up the entire form) to resize with it. I tried overriding WM_SIZE, but it won't let me use...
m_ctrlListBox.SetWindowPos()
or
m_ctrlListBox.MoveWindow()
It crashes in both functions on ASSERT(::IsWindow(m_hWnd));
How else would I resize it?
|
|
|
|
|
The problem is that the HWNDs aren't associated with your member variables until after the window is created, but the form receives a resize before this association. Another WM_SIZE is sent after creation, so the easiest way to fix this problem is:
CSomeClass::OnSize(....)
{
if (m_ctrlListBox.GetSafeHwnd() != NULL)
{
m_ctrlListBox.MoveWindow(....);
}
}
See how that goes. Hope it helps!
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Ok here's what I have now. It doesn't crash, but it doesn't resize either. The debugger shows it gets into the if statement, and the coordinates seem correct. Maybe when I call UpdateWindow() it redraws the listbox from the dialog template, intead of the new resized listbox.
void CMyView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
if( m_ctrlListBox.GetSafeHwnd() != NULL )
{
CRect rectWindow;
GetWindowRect(rectWindow);
m_ctrlListBox.SetWindowPos(&CWnd::wndTopMost, rectWindow.left, rectWindow.top, cx, cy, NULL);
UpdateWindow();
}
}
Any Ideas?
|
|
|
|
|
OK, I tried creating a dummy SDI app, added my Listbox, and created a CListbox control for it. Here's my OnSize handler, which seems to work just fine:
void CTestSDIView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
if (m_ctrlListbox.GetSafeHwnd())
{
m_ctrlListbox.MoveWindow(0, 0, cx, cy, TRUE);
}
}
I also thought it may have to do with the subtle difference between UpdateWindow() and Invalidate(), but that didn't seem to fix your code. I guess that's why I always try and use MoveWindow where possible! Note that MoveWindow coordinates are client coordinates relative to the parent FormView, hence the 0, 0 top left coordinates.
Hope this helps.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
|
SendMessage(hwnd, WM_LBUTTONDOWN, (WPARAM)(fill this out, use your help),(LPARAM)(same here..));
Piece of cake.
|
|
|
|
|
You want to send a message? How about the apply named SendMessage function?
SendMessage(hWnd, WM_LBUTTONDOWN, 0, 0 ), Doh!
|
|
|
|
|
|
I think it's the only way so try again
|
|
|
|
|
Since you didn't get this answered, what seems to be the problem??
Is the hWnd parameter the button you are trying to invoke? Perhaps you could post the problem code so it can be ignored.
|
|
|
|
|
|
One possible way is using API mouse_event
::mouse_event ( MOUSEEVENTF_LEFTDOWN , mouseX , mouseY , NULL , NULL )
look in MSDN for full description of MouseX , MouseY .
|
|
|
|
|
I have a template which should take any type of input such as int, float, or string and return a value.
template<typename T> void GetParmValue(T& value)
{
std::string& str = GetSomeString();
std::istringstream iss(str);
iss >> value;
}
If value is of type std::string then istringstream only gives me the first part of the string. It's spliting the string at the white space.
For instance:
std::string value;
std::istringstream iss("Test 123");
iss >> value;
value is now "Test" and not "Test 123".
Any ideas on how to get around this?
|
|
|
|
|
You'll have to use the getline() function to get the compleate string.
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|