|
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
|
|
|
|
|
Hey all,
This is a bit of a stupid question and probably has an obvious answer, but ill ask anyways.
Ive created a Win32 project in .NET that outputs as a DLL. In it ive added 2 classes and put all my code in, and now i want to call it in either C# or MC++. Problem is, i dont know how to add it at all (in C# its under project->Add reference i think, but it keeps reporting that it cannot add it bcos its not a .NET assembly). Can anybody give a quick pointer ??
Thanks in advance
Ubersnack
Where theres a will, theres another money-grabbing no-good....
|
|
|
|
|
Well if you created a Win32 dll than that obviously is not an assembly - you need to create a .Net dll (which is an assembly essentially). Or use pInvoke to call the win32 dll from C#.
|
|
|
|
|
If I compile a code that uses MFC the size goes about 36KB. If i compile almost same code tht doesnt use MFC its size goes to 56KB.
How can I reduce the size of my exe file.
In my dream, I was dorwning my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
But the 36k is without the mfc dll. Trust me, in the end, a program with mfc is _much_ bigger than a plain C one
|
|
|
|
|
Hi!
I am writing a custom window control in MFC: a tab control.
CWnd
A
|
|
MyTab
class MyTab : protected CWnd {
public:
void add(const CString& title, CDialog* dlg);
...
protected:
...
private:
...
};
Everything goes well. Now I want to seperate interfaces from implementation theorically:
CWnd ITab (abstract class as interface)
A A
| /
| /
MyTab
class ITab {
public:
virtual void add(const CString& title, CDialog* dlg)=0;
};
class MyTab : public ITab, protected CWnd {
public:
virtual void add(const CString& title, CDialog* dlg);
...
protected:
...
private:
...
};
This time, the problem exist: there is no HWND attached.
Does anyone know how to solve this? Or is there an alternative design?
Any reply would be appreciated.
sovann.
Why waste time learning while ignorence is instantaneous ? [Hobbes]
|
|
|
|
|
Sovann wrote:
This time, the problem exist: there is no HWND attached.
I have not understood what it means (hwnd of what???), but I want to give you small advice: mfc classes must be first at deriving order (MSDN says that). Swap 'public ITab' and 'protected CWnd', otherwise you will have a problems
|
|
|
|
|
I've set a waitable timer (Create/SetWaitableTimer API) to 10 seconds. Since it's been
created in a window, I can't use WaitForxxxObjectxxx sync function. So I wanna use a
feature that SetWaitableTimer encapsulates, a call for completion routine.
How can I assure the call for 'PTIMERAPCROUTINE' when a the timer has elapsed??? I read the the creating thread must be 'alert' , but I don't want to use the sync API's.
HELP!
--BlackSmith--
/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
|
|
|
|
|
BlackSmith wrote:
I can't use WaitForxxxObjectxxx sync function.
But you can use the MsgWaitForMultipleObjects
My latest article:
SQL Server DO's and DONT's[^]
|
|
|
|
|
hi there,
I have a console project where i wanted to use the exit() function, but no way, the linker does not recognize it. MSDN says it is defined in <stdlib.h> which, of course, i have included in the file. Any idea ?
#include <stdlib.h>
#include <stdio.h>
void main(void)
{
exit(0);
}
(Yes, I know, my code sample is ridiculous )
Thanks
~RaGE();
|
|
|
|
|
You'll need this too:
#include <process.h>
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|