|
Great ideas people! I am going to try all of these just to see what works and what don't.
|
|
|
|
|
If you have a custom mainframe class (RegisterWndClass()) you can just do a FindWindow(clasname, window caption) and then send a message to the HWND that gets returned.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
I'm working on an ATL based control with addition of WTL to support a GUI that will operate within the control's client area. The problem I'm having is getting a regular menu bar to operate within the control. Since ActiveX controls can't support a menu bar, I thought I could use a command bar to contain the menu.
WTL provides a CCommandBarCtrl class that seems to handle this very nicely but the resulting menu bar doesn't handle mouse clicks correctly. Basically the menu bar shows up and each menu highlights as I mouse over them, but they do not respond to mouse clicks. Additonally if I use a keyboard shortcut to select the menu, the application freezes with the menu left flashing. Using Spy++, I can see a continuous flood of WM_NOTIFY messages during the freeze.
I have the command bar operating as a child of a CFrameWindowImpl class which is a child of the control's window. It also integrates with several toolbars within a rebar control. Here's how I create the command bar and setup the menu:
m_CmdBar.Create(m_hWnd, rcDefault, NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE, 0, ATL_IDW_COMMAND_BAR);
m_CmdBar.AttachMenu(LoadMenu(_Module.m_hInst, MAKEINTRESOURCE(IDR_MAINFRAME)));
m_CmdBar.LoadImages(IDR_TBARMAIN);
CreateSimpleReBar(ATL_SIMPLE_REBAR_STYLE);
AddSimpleReBarBand(m_CmdBar, NULL, TRUE);
I believe this works fine in a regular application where the command bar is a child of CMainFrame, but it behaves strangely in my control.
Any help would be appreciated.
- Oliver
|
|
|
|
|
Have you added REFLECT_NOTIFICATIONS and DEFAULT_REFLECTION_HANDLER to the message maps?
|
|
|
|
|
I added those macros as you suggested but they had no effect.
Thanks anyway.
|
|
|
|
|
#include <iostream>
What is wrong with the below code, i can never get this to work:
---------
#include <iostream>
using namespace std;
int main()
{
ofstream s;
s.open("file.txt",ios::out);
return 0;
}
-----------
and here are my errors:
's' uses undefined class 'basic_ofstream<char,struct std::char_traits<char=""> >'
Now, I dont know what anyone else thinks but these error messages arent very intuitive... Can anybody see what I am doing wrong, and more importantly give me some pearls of wisdom when it comes to understanding these kind of messages. I often get a different one about basic_string when trying to use std::string's
Any help/advice appreciated!
ben
|
|
|
|
|
Well, I'm not sure if this is the problem or just a typo, but your #include statement isn't including anything. I believe it should be #include <fstream> Hope that helps.
|
|
|
|
|
Oops. These posts are in HTML aren't they. #include <fstream> is what I meant.
|
|
|
|
|
You didn't include the right header, that's all.
#include <fstream>
--Mike--
http://home.inreach.com/mdunn/
We've secretly replaced the msdn.microsoft.com servers with Atari 800XLs. Let's see if anyone notices....
|
|
|
|
|
Hi,
Your message doesn't show what files you included, and your problem is
not well understood, but I'll try something and hope they will be helpfull:
include fstream.h, but don't write .h . Like this: #include <fstream>
The reason for this is that you're using the namespace std and there are
certain H files that are already included so the .h causes problems.
Let me know if it works, and if not, try to explain your problem better.
which compiler are you using?
Meni
|
|
|
|
|
Can any body tell me how to get the desktop icon?
|
|
|
|
|
Can any body tell me how to get the desktop icon?
|
|
|
|
|
I know it's not the best perceived wisdom (he said, donning a mega-flame suit), but I want to add a menu to a MDI Child window, i.e. a class derived from CMDIChildWnd.
I think I actually did this once by mistake when but a boy VC++ programmer, however, now that I want to do this I can't !!!
All help and pointers appreciate, anonymouse also!
Old Simon HB9DRV
|
|
|
|
|
How can i resize my dialog box by code???
NAPS_69
|
|
|
|
|
Of course. Use MoveWindow. Check MSDN library for details
modified 16-Sep-18 21:01pm.
|
|
|
|
|
I like to use SetWindowPos()
|
|
|
|
|
I concur - SetWindowPos allows you to size a window without having to know it's X and Y position, and move it without having to know it's size. Also allows you to set the z order.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
OK, here's the deal. I'm writing this program, and it creates a couple of edit boxes on a dialog. Now I'm ready to attach variables to these edit boxes, but when I try to do this I keep getting an error when the program executes. If I put the edit boxes on the dialog with the resource editor and then attach variables with Class Wizard everything is fine, but if I try to attach the variables myself without Class Wizard the program doesn't work. Anyone know what I'm doing wrong?
|
|
|
|
|
When you say "it creates a couple of edit boxes on a dialog" what exactly do you mean?
|
|
|
|
|
What I mean is that I added a couple of CEdit member variables to the dialog class and then called the Create() method on them in the dialog's OnInitDialog() function.
|
|
|
|
|
OK, I'm with you so far. Now when you say "attach variables to these edit boxes", how, when, and where are you doing that?
|
|
|
|
|
OK, let me see if I can clear this up. If I'm going to use Class Wizard what I would do is after I've added the control to the dialog I'd start class wizard. I'd go to the Member Variables tab, click on the ID of the edit control and click the Add Variable button. This would create a variable and link it to the edit control so that I could call UpdateData() to send and recieve the text of the control.
That explains what I'm trying to do now I'll tell you how I've been trying to do it. I added a member variable to the dialog, initialized it in the dialogs constructor, and then added a line like
DDX_Text(pDX, IDC_EDIT1, integer);
to DoDataExchange(). IDC_EDIT1 is the control ID and integer is the variable that I'm trying to link to it. As far as I can tell this is exactly what Class Wizard does.
|
|
|
|
|
First, as Mr. Dunn, has pointed out we would need the error message to know for sure, I would wager that what your getting is an assertion and if you go to the point of the assertion it is complaining about an hwnd not being valid or something to that affect.
I would think maybe that the problem is that DoDataExchange is getting called before you actually create the controls themeselves in OnInitDialog.
I would suggest you do this, if you have not already done it, put a break point in DoDataExchange, and one in OnInitDialog. Start the dialog, see which one the app reaches first.
I will confess that I have never tried to do things quite the way you describe, I kind of like the "Visual" part of "Visual C++". I would be interested to found out whats happening.
|
|
|
|
|
Actually, I've found that this is exactly what is happening. Good analysis, thanks.
|
|
|
|
|
You said you're getting an error message. What error? What does GetLastError() return?
--Mike--
http://home.inreach.com/mdunn/
We've secretly replaced the msdn.microsoft.com servers with Atari 800XLs. Let's see if anyone notices....
|
|
|
|