|
Regarding casting: there's a nice article on DevX about casting:
http://gethelp.devx.com/techtips/cpp_pro/10min/2001/july/10min0701.asp
happy hunting
Steen
|
|
|
|
|
It sounds like your design may be in error. In a propelry designed MFC app, there should be no need to call a function like SetUsers() externally from a view.
A view has two purposes:
1) It displays a document.
2) It handles UI commands.
The name of the fuction SetUsers() makes me think that your view is storing data.
|
|
|
|
|
Is there another way to solve the problem?
In CMainFrame I handle several menu choices. When a the user clicks in the menu I want the FlexGrid that's a member of CTableView to change. For example the number of colomns and the caption of each row should change when the user make different choices. SetUsers() is public and a member of CTableView, in this function I update the table when the user has pressed a choice called "manage users". I thought this would be the right way to go...call this function from CMainFrame where I handle onManageUsers().
Is the design in error?
Oys
|
|
|
|
|
If all the processing in OnManageUsers() can be done in CTableView then you should certainly let that class handle the menu choice (i.e. put the ON_COMMAND macro in CTableView's message map instead of putting it in CMainFrame's map). If some of the processing (such as updating the view) is done in the view, while other things is done in the frame you have a couple of options:
( in the code below I deliberately omit all semicolons at line ends - they will probably be translated into smileys
1) put OnManageUsers in CTableView, and use SendMessage/PostMessage to let CMainFrame do it's thing. You can make a private message (#define WM_MANAGEUSERS WM_APP + 1, for instance). In CTableView:
CTabelView::OnManageUsers()
{
... // do stuff
GetParentFrame()->SendMessage(WM_MANAGEUSERS, (WPARAM)something, (LPARAM)somethingelse)
... // do some more stuff
}
2) put OnManageUsers() in CMainFrame. Let it do whatever modifications is needed. The result of the modifications should somehow be available in the document class (CDocument derivate). At the end of OnManageUsers call the UpdateAllViews method of the document class. If you have more than one document open at a time this method is bad! UpdateAllViews will call all OnUpdate handlers in the view classes. In CTableView, let OnUpdate do the updating of the UI.
3) Let the document handle OnManageUsers() and let it notify the frame and any views.
Hope this helps
hope this helps
Steen.
|
|
|
|
|
It is possible to get a text underlined when you drag the mouse over the text?
OyS
|
|
|
|
|
Can you be more specific about what type of text you require to be highlighted. Is it on a button? Edit box? etc
Matt
------
Accept that some days you are the pigeon and some days the statue.
|
|
|
|
|
Thanks for your interest. It's just a static text. I have a single document with two views and in the left view I have several static texts. The static text are menu choices. When I drag the mouse over the text I want to underline it. When I click on the text I want it to get another color. I managed to get the the text to respond to click by OnLButtonDown() and OnMouseMove() to change cursor.
OyS
|
|
|
|
|
What are some good ones?
In particular I am looking for controls that would be useful for a touch screen application (pop-up virtual keyboards, etc.), also database aware controls using OLE DB.
|
|
|
|
|
Hi,
I need to read up on unicode, typically UTF-8
could someone please suggest some links or articles ?
thanx in advance
Noman
|
|
|
|
|
I'm adding controls to a dialog, and then I cannot add any more, is there a finite number of controls that I can add to a dialog?? How do I increase this number....??
TIA
Senior Test Engineer
GLI Australia
www.gli.com.au
|
|
|
|
|
IIRC you can only have 255 (or 256?) controls in a dialog resource. If you need more, you must create the controls at runtime.
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
Is it possible to register multiple file extensions with an SDI application?
I tried doing the following, but this strange box pops up (new document) but if I pick any choice but the first, an error occurs. Should I create a different document class to handle each file extension type? Or is there an easier way?
AddDocTemplate(new CSingleDocTemplate(IDR_FILETYPE1,
RUNTIME_CLASS(CTest2Doc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CTest2View)));
AddDocTemplate(new CSingleDocTemplate(IDR_FILETYPE2,
RUNTIME_CLASS(CTest2Doc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CTest2View)));
IDR_FILETYPE1 is "sdi app\n\n1\nfiles (*.txt)\n.txt\npart 6-1\npart 7-1"
IDR_FILETYPE2 is "sdi app\n\n1\nfiles2 (*.doc)\n.wsf\npart 6-2\npart 7-2"
--
Peace,
Amit Jain
|
|
|
|
|
Check the Microsoft Knowledge Base ( Q198538 ).
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Got it, thanks =)
--
Peace,
Amit Jain
|
|
|
|
|
How can I change the font of a CStatic control?
Thanks,
Joseph LeBlanc
unixd0od@hotmail.com
|
|
|
|
|
Hi...
Use the CStatic::GetDC() function to get the device context of the static control.
Then u can use the CDC's font manipulation functions to play with fonts.
Happy coding,
Regards,
Rejeesh
|
|
|
|
|
You can use CWnd::SetFont(), and I always use CFont::CreatePointFont() for convenience.
Cheers,
Bob.
|
|
|
|
|
Hi,
I am adding an automatically resizable dialogbar into my MFC program. But it can not automatically resize when the window size is changed. Can you tell me the reason and how to implement this? Thanks in advance.
Kidd
|
|
|
|
|
If I throw and catch an exception in VC++ I see something like this in the debug window:
First-chance exception in DF.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
Is there anyway to prevent this message from being displayed?
|
|
|
|
|
If I throw and catch an exception in VC++ I see something like this in the debug window:
First-chance exception in DF.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
Is there anyway to prevent this message from being displayed?
|
|
|
|
|
There might be a pragma, but what's the problem ?
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
I would like to get an answer as well. When a server program pops up one of those messages phones start ringing. If it is a regular program, all I usually have to do is clear the error message. If it is a service though, there is no visible message to clear and the only resort is to re-start the computer
|
|
|
|
|
Why would your server program run your code via Visual C++ in debug mode ? Unless I read you wrong, you're saying you get a trace message, right ?
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
I lead a team of developers of different skill levels. The assertions are the only way to let someone know where the problem is. We get all sorts of crap data sent from the users, which manages to set up "impossible" situations that were not trapped in the code. The asserts capture the condition, I just wish I could get them to write to a file and hopefully let the programs continue on their way
|
|
|
|
|
So, if you must, write your own replacement for assert. It's just a macro. Personally I'd never use assert in the way it sounds like you're using it.
Assert is supposed to be disabled as soon as you move out of a debug environment. It's for checking that your program is doing what you thought it was, not for checking your users are doing what they ought to do. That's input validation which, in a serious production application, is usually a significant proportion of the program code.
An assert failure ought to ring alarm bells.
However AFAIK an assert failure just raises an exception. You can probably catch it and do what you like with it.
|
|
|
|