|
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I have a CDateTimeCtrl on my dialog. Through this I can choose any date in given range from drop down. But currently user is also allowed to press numeric keys to set the date. Is there any way to stop user from typing in it. I want, he should only be able to select the date from drop-down and I don't want to disable the control.
I have checked the "AllowEdit" property but that is different thing. Currently it is set to false.
|
|
|
|
|
You may derive a class from CDateTimeCtrl() and add a WM_CHAR / OnChar() handler that does nothing or calls the base class handler for non-digit chars only.
I've just tested it. It does not effect keys pressed in the drop down calendar and still allows cursor keys and TAB in the edit control.
|
|
|
|
|
Thanks Jochen, you are right. That way it will work. But for such a small requirement, I don't want to do big changes and also I don't want to go for pretranslate message. Is there any way to handle WM_CHAR/OnChar events for the date control on the same dialog class?
|
|
|
|
|
You are using MFC, so you don't need to handle PreTranslateMessage() . Just use the wizard to derive a class, use the message properties to add the WM_CHAR handler, and comment the line calling CDateTimeCtrl::OnChar() . Done with a few mouse clicks. All you need to type in using the keyboard is the name of the drived class, the comment chars, and replacing the CDateTimeCtrl by your class name in your code.
The edit control of CDateTimeCtrl is not accessible. So it can't be done in the dialog. Even when it would be possible: It is always better to perform such things in the control rather than in the dialog. So it must be done only once and not within every dialog that uses such a control.
|
|
|
|
|
I need to save several ini files into one file, and then read these files from this zip file.
How to use the vc++ to do it?
|
|
|
|
|
Maybe this[^] article might help, there are others as well.
|
|
|
|
|
|
<pre lang="c++">
Image* m_pImage;
CString strTempIMGPath = m_strCurrentImagePath;
wchar_t szFile[256] = {0};
char *pStr = strTempIMGPath.GetBuffer(0);
int size = MultiByteToWideChar(GetACP(), 0, pStr, -1, NULL, 0);
MultiByteToWideChar(GetACP(), 0, pStr, -1, szFile, size);
strTempIMGPath.ReleaseBuffer();
if (m_pImage != NULL)
{
delete m_pImage;
m_pImage = NULL;
}
<b> m_pImage = new Image(szFile, FALSE);</b>
if(m_pImage->GetLastStatus() == Gdiplus::Status::Ok)
{
...
}
After this statement,m_pImage = new Image(szFile, FALSE)
the m_pImage is NULL, I do not know why create Image failed, after debug that I find that the szFile is a right PNG image file path.
The last code used in a CDialog form, I use the CDialog::DoModel() to show this dialog in the
CMyApp::InitInstance()
I do not know whether I use this class Image too early, or I need use some code to initialize the GDI+ library?
|
|
|
|
|
replace the first line with this:
Image* m_pImage = NULL;
Otherwise, m_pImage is not NULL, and you are trying to delete uninitialised pointer, leadding to memory corruption
|
|
|
|
|
ULONG_PTR m_gdiplusToken;
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
The GdiplusStartup function initializes GDI+. Call GdiplusStartup before making any other GDI+ calls, and call GdiplusShutdown when you have finished using GDI+.
|
|
|
|
|
Very Good answer, thank you very very much.
|
|
|
|
|
Hi everybody,
I have a console application, that create a dialog box to show a progress bar. This has worked fine for years (it started as a Visual Studio 6 project, then I migrated it to Studio 2005) Now, I have migrated it to Studio 2010. It still works fine under Windows 7, but under XP, the dialog box returns -1, with a GetLastError() of 0. When I look at the messages sent to the dialog box, then I see WM_SETFONT, followed by WM_DESTROY and WM_NCDESTROY. I call it as
DialogBox (hInstance, MAKEINTRESOURCE (IDD_MAPPER), HWND_DESKTOP, DialogProc), where DialogProc is defined as
INT_PTR CALLBACK DialogProc(HWND, UINT, WPARAM, LPARAM);
Like I said: it all worked fine and still does in Windows 7, but XP does not seem to co-operate anymore.
Anybody any ideas? Would be grately appreciated!
Thanks in advance,
William
|
|
|
|
|
Is you Windows XP updated to (at least) Service Pack 2 ?
(see here here[^])
Veni, vidi, vici.
|
|
|
|
|
It is most likely the manifest. When I converted my projects to VS2010, it changed all my manifests to use urn:schemas-microsoft-com:asm.v2 in this line:
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0>
You need to change it back to v1.
Basically, manifest should look similar to:
="1.0"="UTF-8"="yes"
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="2.0.1.1"
processorArchitecture="X86"
name="myAwesomeApp"
type="win32"
/>
<description>Awesome</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
Also, please check if you still using the manifest loaded via RT_MANIFEST resource. You need to delete this from resource and use the project settings. VS2010 has a habit of assigning RT_MANIFEST to 2, making the program unusable under XP.
And of cause you need to check this linker option: MinimumRequiredVersion. It should be 5.00.
|
|
|
|
|
Thanks for your answer, but I cannot find much out of the ordinary. I am not very well familiar with the manifest, but it looks to be generated by Studio2010? Anyway, it reads:
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
There is no RT_MANIFEST mentioned in the resource
Also, the MinimumRequiredVersion is left blank, so I don't expect any difficulties there!
In any case: the program itself runs and it does everything up untill the point that I start the dialog box. (and everything after that dialogbox crashes) There are a number of log statements before and after and I see everyone of them. Only everything that occurs from within the dialogbox doe not appear in XP.
|
|
|
|
|
Try to set MinimumRequiredVersion to 5.00
|
|
|
|
|
Just tried that: No change
Thanks anyway
|
|
|
|
|
Is InitCommonControlsEx() of any help?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
YES! Thank you very much! I had commented that one out, since Studio 2005 at the time said it was no longer necessary! Including it again did the trick!
Thank you very much!
|
|
|
|
|
hi,
I study ado program ,when DB restart, normally use _ConnectionPtr's Open to reConnect firstly; but if I don't do it, _RecordsetPtr also can work...why?
|
|
|
|
|
Hi
I did code to draw curves using PolyBezier function. now I want to allow user to draw it using the mouse but I do not know how I can do it how I specify the control points for the curve while user draw the curves using mouse??
can you help me in doing this did lots of search without any result
thanks
|
|
|
|
|
It depends on what you want. You could, for instance, let the user draw the curve, extrapolate control points from the drawn curve (aka x,y positions that the mouse went through), and then use them to calculate a smooth curve. Or you could have the user draw a line, then click a point on that line to create a control point and allow them to move that point. I've seen both.
|
|
|
|
|
Hi,
I have created a COM dll . I'm calling another dll(C#.net dll\assembly)by adding refrence of this .net dll(from project properties) .And i able to access properly.
Now i want to make this .net dll usage should be independent of path. I mean -
I'll not add any reference or give path name in my COM dll Hence my COM dll don't know where this .net dll is located in the system. While COM Dll try to call this .net dll it'll search in whole system & load it.
Kindly please advice the C++ code for this
OR LoadLibrary() is only the method through that only we can load library dynamically(independent of path)
Please advice . Thanks in advance ![Smile | :)](https://www.codeproject.com/script/Forums/Images/smiley_smile.gif)
modified 6-Nov-12 8:05am.
|
|
|
|
|
litu kumar wrote: it'll search in whole system
That is unlikely to be a good idea.
Have you tried to write code that searches for one dll on the system?
What if there are two different versions?
What if there are mapped network drives?
|
|
|
|