Click here to Skip to main content
       

C / C++ / MFC

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
QuestionCEdit controlmembersarfaraznawaz22 May '13 - 20:12 
how to set char limit so that it should not exceed the 11 char .
after exceeding 11 char does not allow to press the key.
any example will helpful
AnswerRe: CEdit controlmemberSivaraman Dhamodharan22 May '13 - 20:25 
Look for implementing Custom DDV (Google for Custom DDV in MFC) (Like Dynamic Data Exchange(DDX), it is Dynamic Data Validation)

AnswerRe: CEdit controlprofessionalJochen Arndt22 May '13 - 21:06 
See CEdit::SetLimitText()[^].
QuestionUsing MagSetImageScalingCallbackmemberthanh_bkhn22 May '13 - 15:55 
Hi everyone,
I need to use MagSetImageScalingCallback to capture the desktop screen. But I cannot find out how to call it correctly. I know it's odd, but do you have any idea about this deprecated function?
AnswerRe: Using MagSetImageScalingCallbackmember«_Superman_»22 May '13 - 16:18 
The documentation link that you provided has some lines in it that I would like to quote here -
Quote:
Note The MagSetImageScalingCallback function is deprecated in Windows 7 and later, and should not be used in new applications. There is no alternate functionality.
Quote:
This function requires Windows Display Driver Model (WDDM)-capable video cards.
Quote:
This function works only when Desktop Window Manager (DWM) is off.

For screen capture, look at the following articles -
Various methods for capturing the screen[^]
Barry's Screen Capture[^]
 
Not sure if this is already mentioned in the articles, but I once captured the screen using the CreateDC API used this way -
HDC hdc = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
You then save the device context in hdc to a file.
Read here for saving the device context -
Converting Device context to images ( PNG , JPEG , BMP , GIF) , Creating PDF & Printing to the Printer[^]
Saving (part of) a Device Context as a Bitmap[^]
«_Superman 
I love work. It gives me something to do between weekends.


Microsoft MVP (Visual C++) (October 2009 - September 2013)

Polymorphism in C

Questionany solution for WSAETIMEDOUT for CAsynSocket::OnConnectmemberForNow22 May '13 - 6:36 
Hi
 
When I first got my laptop last august my application that I was developing (at least the TCP/IP code)
was running fine about now my laptop runs a lot slower I tried to clean it up but it still doesn't
run nearly as fast it did when I bought it
 
towards that end on My CAsyncSocket::OnConnect overridble I am getting the following nErrorCode
 
WSAETIMEDOUT
 
I am wondering what is the best approach to this is modifying a registry key for the TCP/IP time out value (I am running Windows 7)
 
Maybe start clean re-install of Windows
 
Any suggestion appreciated
 
Thanks
SuggestionRe: any solution for WSAETIMEDOUT for CAsynSocket::OnConnectmvpRichard MacCutchan22 May '13 - 21:02 
Don't try solving a problem that may not exist. The first thing you need to do is investigate why the timeout is occurring.
Use the best guess

GeneralRe: any solution for WSAETIMEDOUT for CAsynSocket::OnConnectmemberForNow23 May '13 - 4:32 
My computer has gotten a lot slower since I have gotten it
 
<a href="http://support.microsoft.com/kb/170359">http://support.microsoft.com/kb/170359</a>[<a href="http://support.microsoft.com/kb/170359" target="_blank" title="New Window">^</a>]
 
I tried Microsoft knowledge base 170359 to resolve the problem upping the time out times but didn't seem to work
 
I am thinking of re-installing windows to get the computer back to speed
Questionsource code sudoku cmemberMember 1006942622 May '13 - 3:54 
does anyone have the source code of sudoku?, but that requires us to input numbers and and using C
AnswerRe: source code sudoku cmemberChris Losinger22 May '13 - 4:16 
yes, somebody probably does

GeneralRe: source code sudoku cmvpCPallini22 May '13 - 22:54 
Definitely.
Thumbs Up | :thumbsup:
Veni, vidi, vici.

QuestionC++ Syntax failure ?memberEngeltje22 May '13 - 3:40 
Can anyone explain me why the following C++ snippet does compile and not end up in a compiler error ?
int main()
{
  double d;
  d = 0,2;      // WHY IS THIS NOT A COMPILER ERROR ?

  return 0;
}
I would expect the double assignment should be
  double d;
  d = 0.2;
Because I couldn't believe it, I tried VisualStudio 2010, -2005 AND -6, all three compiled with 0 errors, 0 warnings...
AnswerRe: C++ Syntax failure ?professionalJochen Arndt22 May '13 - 4:11 
See the C comma operator[^]
GeneralRe: C++ Syntax failure ?memberEngeltje22 May '13 - 4:25 
How simple can it be... Thank you Jochen.
And thanks to CppCheck for finding the mistake!
(see cppcheck.sourceforge.net)
Questionerror handling in c++ dllmembervenkatesh5286721 May '13 - 19:39 
Hi,
I have one function which is return string array in my C++ dll .from this function how can return error .please help me .
Thanks
AnswerRe: error handling in c++ dllmvpRichard MacCutchan21 May '13 - 21:05 
venkatesh52867 wrote:
how can return error

Use SetLastError() to set some unique error code, and return NULL instead of a valid pointer.
Use the best guess

QuestionMFC SetTimer() questionmemberecony21 May '13 - 7:13 
In a dialog, WM_PAINT message handler, I set a timer.
void CXYZDlg::OnPaint()
{... SetTimer(12, 2500, NULL);} 
 
in the OnTimer(),I found I have to set it again, then it goes into
the breakpoint in OnTimer() repeatedly. otherwise, it only goes into the OnTimer() function once.
 
<pre lang="c++">void CXYZ::OnTimer(UINT_PTR nIDEvent)
{
if (g_Scroll == 1) {
		if ( sc< 16 ){
			BuzzerOnce(1);
			SC++;
		}
		else
			sc = 1;
	}
 
	...
	SetTimer(1361, 2500, NULL);  //Have to set this, other wise OnTimer only runs once. I am confused with this statement.
	CDialog::OnTimer(nIDEvent);
}

AnswerRe: MFC SetTimer() questionmemberDavidCrow21 May '13 - 9:36 
Set the timer once in the dialog's OnInitDialog() method.

"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


GeneralRe: MFC SetTimer() questionmemberecony21 May '13 - 15:32 
Thanks, but, it's like in the OnPaint();
AnswerRe: MFC SetTimer() questionmemberthanh_bkhn21 May '13 - 16:46 
I don't understand why you have to set the timer again because it will repeatedly called. If you want to handle multiple timers, you can call SetTimer() with multiple Id, for example
 
SetTimer(12, 2500, NULL);
SetTimer(1361, 2500, NULL);
 
Then in the OnTimer(UINT nIDEvent), you can process it as below:
if(nIDEvent == 12){
...
}
if(nIDEvent == 1361){
...
}

AnswerRe: MFC SetTimer() questionmvpRichard MacCutchan21 May '13 - 21:04 
That means the timer will be set every time a WM_PAINT message is received. A very bad idea, since you have no control over it.
Use the best guess

GeneralRe: MFC SetTimer() questionmemberecony22 May '13 - 15:02 
Tried to put SetTimer() in OnInitDialog(), just trigger OnTimer() once, so weird.
But it is a old project wrote by others, I just tried to add a timer, to do something.
 
I wonder timer is a resource, like c++ "new" something, right? it will take up memory, if settimer repeatedly, no killertimer, then that means it will use more and more memory, right?
GeneralRe: MFC SetTimer() questionmemberecony22 May '13 - 17:23 
I have a new question about SetTimer(), if I use a unique ID, say,
SetTimer(2, 1000, NULL), then, I repeat this statement many times,
SetTimer(2, 1000, NULL),....
 
Then, I set one timer named 2 many times, or I set many timer with same name 2? that is, after 100 SetTimer(2,1000,NULL); there is only one Timer with name 2 in the system. or there are 100 pcs Timer with name 2 in the system?
GeneralRe: MFC SetTimer() questionmvpRichard MacCutchan22 May '13 - 21:00 
In this case you are just resetting Timer2 with every call, but why do that - again it serves no purpose. Maybe it would be better if you actually explained what problem you are trying to solve.
Use the best guess

GeneralRe: MFC SetTimer() questionmemberecony23 May '13 - 0:09 
Thanks, I just want a module to work, so I can test my new function in that module.
No enough time to find why the timer needs to reset.
 
Then you think in OnTimer() function, I use SetTimer(2,1000,NULL), it's not create a new Timer, just reset
the ID=2 Timer, right?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 25 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid