Click here to Skip to main content
16,018,347 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Multilingual Support: Use "String Tables" instead of creating a new set of Dialogs for each supported language Pin
Hamid Taebi23-Feb-07 18:54
professionalHamid Taebi23-Feb-07 18:54 
QuestionNot drawing full dialog Pin
aquawicket23-Feb-07 14:14
aquawicket23-Feb-07 14:14 
AnswerRe: Not drawing full dialog Pin
David Crow23-Feb-07 14:59
David Crow23-Feb-07 14:59 
GeneralRe: Not drawing full dialog Pin
aquawicket23-Feb-07 15:30
aquawicket23-Feb-07 15:30 
GeneralRe: Not drawing full dialog Pin
Rajesh R Subramanian23-Feb-07 18:43
professionalRajesh R Subramanian23-Feb-07 18:43 
QuestionVisual styles without MFC Pin
Lamgi-Mari23-Feb-07 12:01
Lamgi-Mari23-Feb-07 12:01 
AnswerRe: Visual styles without MFC Pin
John R. Shaw23-Feb-07 16:51
John R. Shaw23-Feb-07 16:51 
QuestionTired of copy/pasting code....... Pin
pblais23-Feb-07 10:40
pblais23-Feb-07 10:40 
A long time ago, I needed a way to put information into edit boxes etc. in my MFC dialog applications "on the fly". That is, I didn't want to wait till a function terminated and the particular window was updated/repainted. I wanted to see the data change real time as it was running. I didn't want to use a timer so I came up with the following function.

void	DisplayNow(int nID, LPCTSTR lpszString)<br />
{<br />
	CWnd*		pDISPLAY_Wnd = GetDlgItem(nID);<br />
<br />
	pDISPLAY_Wnd->SetWindowText(lpszString);<br />
	pDISPLAY_Wnd->UpdateWindow();<br />
}


where nID is the ID of the edit box etc. that I want to display the data in

I overloaded more versions of the same functions for integers, floats etc. I am only showing the version that does strings here.

Anyways these functions have allowed me to display data on the fly and I have been quite happy with them for quite some time now.

But, anytime I want to use them, I have to copy/paste them into the application's dialog file. At one point, I tried to wrap them in a class and use them that way but the compiler burped hard at that because the handle to the window (pDISPLAY_Wnd) is not known at compile/link time. So I continued copy/pasting.

Recently I tried to put all the functions into a file called DisplayNow.cpp and DisplayNow.h hoping that, even though I couldn't make them into a class, this would prevent me from the copy/paste thing.

So DisplayNow.cpp looks like this:

#include "stdafx.h"<br />
#include "DisplayNow.h"<br />
<br />
void	DisplayNow(int nID, LPCTSTR lpszString)<br />
{<br />
	CWnd*		pDISPLAY_Wnd = GetDlgItem(nID);<br />
<br />
	pDISPLAY_Wnd->SetWindowText(lpszString);<br />
	pDISPLAY_Wnd->UpdateWindow();<br />
}


and DisplayNow.h looks like this:

void DisplayNow(int nID, LPCTSTR lpszString);

Now, when I try to compile, I get this error:

DisplayNow.cpp(6) : error C2660: 'GetDlgItem' : function does not take 1 parameters

Am I destined to being forced to copy/paste all these functions into very new application that I create????Frown | :(

Thank you in advance
Pierre
AnswerRe: Tired of copy/pasting code....... [modified] Pin
Mark Salsbery23-Feb-07 12:23
Mark Salsbery23-Feb-07 12:23 
AnswerRe: Tired of copy/pasting code....... Pin
PJ Arends23-Feb-07 12:33
professionalPJ Arends23-Feb-07 12:33 
AnswerRe: Tired of copy/pasting code....... Pin
S Douglas24-Feb-07 23:28
professionalS Douglas24-Feb-07 23:28 
QuestionActiveX returning custom types from methods?? Pin
jhinze23-Feb-07 10:13
jhinze23-Feb-07 10:13 
QuestionReferences vs. Pointers Pin
Yonggoo23-Feb-07 9:15
Yonggoo23-Feb-07 9:15 
AnswerRe: References vs. Pointers Pin
Joe Woodbury23-Feb-07 9:32
professionalJoe Woodbury23-Feb-07 9:32 
GeneralRe: References vs. Pointers Pin
Yonggoo23-Feb-07 9:46
Yonggoo23-Feb-07 9:46 
GeneralRe: References vs. Pointers Pin
David Crow23-Feb-07 10:28
David Crow23-Feb-07 10:28 
GeneralRe: References vs. Pointers Pin
Joe Woodbury23-Feb-07 10:34
professionalJoe Woodbury23-Feb-07 10:34 
GeneralRe: References vs. Pointers Pin
Jörgen Sigvardsson23-Feb-07 11:35
Jörgen Sigvardsson23-Feb-07 11:35 
GeneralRe: References vs. Pointers Pin
PJ Arends23-Feb-07 12:54
professionalPJ Arends23-Feb-07 12:54 
GeneralRe: References vs. Pointers Pin
Jörgen Sigvardsson23-Feb-07 13:42
Jörgen Sigvardsson23-Feb-07 13:42 
AnswerRe: References vs. Pointers Pin
Mark Salsbery23-Feb-07 10:44
Mark Salsbery23-Feb-07 10:44 
QuestionStrange errors related to getline()... Pin
CoffeeAddict1923-Feb-07 9:12
CoffeeAddict1923-Feb-07 9:12 
AnswerRe: Strange errors related to getline()... Pin
Newbie0023-Feb-07 9:51
Newbie0023-Feb-07 9:51 
GeneralRe: Strange errors related to getline()... Pin
CoffeeAddict1923-Feb-07 9:55
CoffeeAddict1923-Feb-07 9:55 
QuestionRe: Strange errors related to getline()... Pin
Newbie0023-Feb-07 10:00
Newbie0023-Feb-07 10:00 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.