|
Hello,
I just can't find how to access my current Doc or View class from my Dialog. I have a simple document application, and my dialog is a toolbar (http://www.codeproject.com/miscctrl/rollupctrl.asp). If I click on a button of my toolbar, it executes :
void CFooDlg::OnButtonMyAction()
So I want here to access my current document, update it, and then update the view.
It looks like a very basic question, but I can't figure out how to do that.
Thank you for your help,
loic
|
|
|
|
|
If your dialog is a toolbar, wht you shoukld do is handle the action (button pressed, or other) on your doc class. You can use the class wizard for that, or you can do it by hand and add an entry on the DOC message map to catch the action.
Good luck.
Hernan
|
|
|
|
|
thx, I will do that through the associate view, so I can easily manage the redraw of the data.
loic
|
|
|
|
|
Easier and better if you do that in the document and then call
UpdateAllViews(NULL);
|
|
|
|
|
Thank you! With all the possibilities, creating a well organised structure for a windows program is not so easy, especially when wanting to do it as modular as possible.
loic
|
|
|
|
|
Hi all,
I created a window( I didn't call the ShowWindow(), so it is unseen) and create a child window: a system tray icon and a popup menu attached to this icon. I want to disable some menu item of that popup menu.
I called the enable() method of that CMENU object, but no result. The return value are correct.
What can I do?
Need your help.
Luara
|
|
|
|
|
EIther you need to map the equivalent ON_COMMAND_UI handlers which when not present cause MFC code to enable a menu item by default if it has a handler or map the WM_INITMENUPOPUP message and enable/disable the items there.
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
I need to validate the user input for a textbox for a National Insurance Number format i.e. AANNNNNNA. A = alpha and N = numeric
Can anyone suggest a neat way to do this?
|
|
|
|
|
Yes, use regular expressions. You can use RegEx++ from the boost library (www.boost.org). http://www.javaworld.com/javaworld/jw-07-2001/jw-0713-regex.html is the first result of http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=regular+expression+social+security+number&btnG=Google+Search,
but there are plenty more, so have a look around.
|
|
|
|
|
You should not have to compile or link in a whole library to validate the input of one text box.
Look for help topics in MSDN about custom DDV() routines.
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
Can anyone suggest a neat way to do this?
He asked for a neat way. Not an efficient way.
I'm a regular expressions junkie, though. I think it should be part of the C++ language specificatin myself, but that's just me. I accept the overhead of that library because of what it gives you. Again, that's just me.
-Matt
p.s. Here's an article on using Regex++ in your app http://www.codeproject.com/string/Regex__.asp
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
What is a "neat" solution? There is only elegant solution. In MFC, I recommend overriding the on-change event handlers and can the edit text for the desirable input.
Kuphryn
|
|
|
|
|
I'm assuming you have an modal dialog for entering a number of values.
First you need to decide when the validation should be performed. Directly when the user is inputing the value into the editbox or when he are done with the input and accepts (presses OK or Enter).
The latter one is easier, in OnOK() call a function which validates the entered value and if it returns true everything is ok and you can close the dialog else you need to pput up some error and let the user try again.
Validating during input is a bit trickier, but if you use a masked edit control it's not that hard. Microsoft has one, Insert ActiveX control - Microsoft Masked Edit Control (msmask32.ocx). I use one from Dundas, which they gave away for free a long time ago! It's a very small part of there Toolbox. You will find several attempts here on CodeProject also... http://www.codeproject.com/editctrl/#Masked%20and%20Validating%20controls[^]
Hope this will help you!
Mike Eriksson
Sonork 100.21825
|
|
|
|
|
Hi
I added the OnPaint() function to my CDialog-based app via the class-wizard. But for some reason it does not get called, why?
As far as I can see classwizard set up everyhting correctly:
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
ON_WM_ERASEBKGND()
ON_WM_PAINT()
void CMyDlg::OnPaint()
{
CPaintDC dc(this);
}
What's going wrong?
thanks in advance,
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
It all looks good to me.
did you include the obvious -- #include <afxwin.h> ?
That would be my only two cents
Jeff Patterson
Programmers speak in Code.
www.anti-dmca.org
|
|
|
|
|
The code looks ok for a window but actually I think the dialog takes care of its painting in the background. Each control does it's own painting when necessary.
Jeff Patterson
Programmers speak in Code.
www.anti-dmca.org
|
|
|
|
|
I am having trouble getting an embedded object to update in my view. I have embedded Excel in a CView. When I change items on the current worksheet, they change on my view just the way they are suppose to but if I issue a command to change worksheets my view does not show the newly active worksheet. If I open the object for editing in another window I can see that the active worksheet has actually change but it is not displayed on my view. If I change the active worksheet in Excel it does change in my view. I must me missing a command to update my view. Can someone help?
Thanks,
Tim
|
|
|
|
|
Hi,
I need to create in separate thread some dialog controlled by CDialog derived class. Thread will create the dialog, process user's actions on it and after closing od dialog, thread can terminate.
I tried to create thread by AfxBeginThread() - worker thread type and i created dialog and called DoModal() in controlling function. But after displaying the dialog it still acts like modal dialog, even if it is in separate thread - i can't click in main application dialog.
How to solve this ?
Thanks
rrrado
|
|
|
|
|
It is surely better to do this with UI threads: Derive from CWinThread to, say CMyThread , override OnInitInstance and display the modal dialog there. To terminate the thread, just return FALSE from OnInitInstance .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I tried that, but it is doing the same thing :
class CMyThread : public CWinThread
{
DECLARE_DYNCREATE(CMyThread)
public:
...
BOOL CMyThread::InitInstance()
{
CMyDialog dlg;
dlg.DoModal();
return TRUE;
}
I made button in mail application dialog, which creates my thread. It displays modal dialog but i still can't access main application dialog until i close thread's dialog
rrrado
|
|
|
|
|
Why not make your dialog modalless?
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
One of the properties of a modal dialog box is absolute focus from the parent window. For more flexibility, use a modeless dialog box another member has mentioned.
Kuphryn
|
|
|
|
|
hi
i am doing a sample project for my knowledge purpose. i am doing a text editor like ms-word. i am not using CEdit control i like to write my own class for displaying text. how can i change the font size and fontface . please guide me.
|
|
|
|
|
There is a WordPad like sample in the Visual C++ Samples. (MSDN search should find it) This should give you a good starting point.
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
thank you very much for your valuable information
|
|
|
|