|
BOOL MyAppDlg::SamplePassArgs(CString *pstr, int dVar, UINT uVar, CString strvar)
Now you may also overload the function
BOOL MyAppDlg::SamplePassArgs(int dvar)
or
BOOL MyAppDlg::SamplePassArgs(CString strvaar)
or
BOOL MyAppDlg::SamplePassArgs()
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
Hi BaldwinMartin,
I'm sorry, I don't understand your reply at all. I'm not using MFC, and I think my function definition was ok, I just didn't know how to call sprintf inside myfunc with the argument list that was passed into myfunc. For example, I want to call myfunc like
myfunc("2 ints: %i, %i\n", 100, 200);
and then inside myfunc call sprintf with the var list. Sorry if I'm not explaining it right...
Thanks for your reply though!
|
|
|
|
|
You need to use va_*() functions.
e.g. :
Format( const char *F, ... )
{
if( !F ) return;
char buff[1024] = '\0';
va_list l;
va_start(l, F);
_vsnprintf(buff, 1020, F, l);
va_end(l);
}
... or you could use the other va_*() functions to walk the argument list and do your own parsing.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
|
Hello all! I'm trying to make a instant messaging app for my home network, and I am using RTF controls for text input and conversation display. I am currently having a problem, though, appending (for testing and later implementation) the string I enter in the text input RTF control to the conversation RTF control preserving all the RTF formatting information. Any ideas on how I would go about doing this?
Sean Payne
|
|
|
|
|
What derived view are you using?
CBL
My neighbours think I am crazy - but they don't know that I have a trampoline. All they see my head bobbing up and down over the fence every five seconds
|
|
|
|
|
Actually, I'm not using a view. The conversation dialog has two CRichEditCtrl controls (I've extended the class for easier RTF information extraction to CString using a function called "CString GetText(bool bGetRTF)" (the bool parameter tells me to get plaintext or RTF formatted info)). So basically, I used Visual C++'s dialog editor and added two Rich Edit controls to the dialog. That's basically my setup. Thanx!
Sean Payne
|
|
|
|
|
If i want to hook a rich text box on a window, what msg's should i be looking for.
I.E. when a rich text box gets data set to it, what kind of WM_ msgs (or EM_) are processed by the system? what should my hook look for?
|
|
|
|
|
Anyone knows how to?
Thanks
~Mike
|
|
|
|
|
Are you looking for the function atoi? this is an old but much maligned function. If it is you you only have to say "Thanks masked man - you have saved my life"
go cobol young man - go cobol
My neighbours think I am crazy - but they don't know that I have a trampoline. All they see my head bobbing up and down over the fence every five seconds
|
|
|
|
|
|
cobol just told you, how to convert from str to int so you have that right?
int x = atoi("123456");
now to change that back to an int?
ok right out of MSDN
char *string, *stopstring;
double x;
long l; // or int
int base;
unsigned long ul;
string = "3.1415926This stopped it";
x = strtod( string, &stopstring );
printf( "string = %s\n", string );
printf(" strtod = %f\n", x );
printf(" Stopped scan at: %s\n\n", stopstring );
string = "-10110134932This stopped it";
l = strtol( string, &stopstring, 10 );
printf( "string = %s", string );
printf(" strtol = %ld", l );
printf(" Stopped scan at: %s", stopstring );
string = "10110134932";
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
You can use the atoi() function if it a CString.
If it is LPTSTR or some other string stuff I prefer writing them on an invisible static text box and retrieving them as an interger.
I hope this helps!
Well... I am a beginner ...
|
|
|
|
|
Scolinks wrote:
You can use the atoi() function if it a CString.
If it is LPTSTR or some other string stuff I prefer writing them on an invisible static text box and retrieving them as an interger.
I hope this helps!
Well... I am a beginner ...
Yuck! (the static text box thing) But forgivable for a beginner (just )
I think it's time you were introduced to the boost library, and in particular the lexical_cast<> template.
Also note that an LPTSTR (long pointer to a TCHAR string) can be one of two things - a pointer to a char array (char *), or a pointer to a wide-char string (wchar_t *, which is a full type in VC.NET, and a typedef for short in VC6)
The T bit is the TCHAR thing mentioned earlier - TCHAR means char or wchar_t, depending on if you are building an ANSI/ASCII version of your code, or a UNICODE one.
I would suggest that you look up the relevant functions for conversions, which can handle unicode or ansi strings as necessary (eg, _tcstoul for converting a LPTSTR to an unsigned long).
HTH
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
Pen pen(m_LineColor,(float)m_LineWidth);
SolidBrush brush(m_FillColor);
...
graphics->DrawPolygon(&pen,ps,p);
graphics->FillPolygon(&brush,ps,p);
...
delete &pen; //
delete &brush; //
Execute application ,'delete &pen' and 'delete &brush' error.
Thanks.
VC/MFC fans.
|
|
|
|
|
Buddy you don' have to worry bout notting. We taka cara you. You no hava delete notting. You trustus.
Go FORTH and smite thine enemy sayeth Prince George
My neighbours think I am crazy - but they don't know that I have a trampoline. All they see my head bobbing up and down over the fence every five seconds
|
|
|
|
|
I.E. You do not and never will have to delete objects that you have defined without the new operator. This is not GDI+ - this is basic C++ .
The fourth moon is casting a shadow over Jupiter at this very moment
My neighbours think I am crazy - but they don't know that I have a trampoline. All they see my head bobbing up and down over the fence every five seconds
|
|
|
|
|
LPRECT rect;<br />
<br />
rect->left = 100;<br />
rect->right = 200;<br />
rect->top = 100;<br />
rect->bottom = 300;
This is the code that should be executed when i click a button. However, when I click it, I get an error, it terminates my process. Why?
|
|
|
|
|
LPRECT rect = new RECT;
rect->left = 100;
rect->right = 200;
rect->top = 100;
rect->bottom = 300;
//must delete rect later;
Thank You
Bo Hunter
|
|
|
|
|
|
Don't use LPRECT. Basically that means CRect *pRect, which is probably not what you really want. Use RECT instead. Then you can create an object just like something else.
MFC uses CRect which can implicitly cast to RECT. This class contains some really handy methods. For instance Width() and Height().
|
|
|
|
|
Hi ,
I've written a Win32 DLL in C that gets called by an application. I spawn a Dialog Box from within this DLL using DialogBox ; I would like to give this box a parent window but I'm not able to find a way to specify a valid parent window handle suitable for a call to DialogBox.
Does anyone know how to achieve that?
Thanks for your time & help
Marc
|
|
|
|
|
The caller should pass a parent window to your code. See various APIs like ShellExecute() that do this.
If you can't change the caller, you'll have to resort to either enumerating windows in the current thread, looking for an overlapped window, or call GetActiveWindow() and hope it's suitable.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
If my rhyme was a drug, I'd sell it by the gram.
|
|
|
|
|
Mike,
Indeed, I can't change the caller so I've used the GetActiveWindow API and this provides me what I was looking for.
Merci beaucoup de ton aide ( j'ai lu sur ton site web personnel que tu as étudié le français ... alors je ne peux résister )
Marc
|
|
|
|
|
Hi..
I used the ADO data bound Dialog wizard to use an access DB table (ID:Autonumber , title:text , description:MEMO)
this code adds a new record:
UpdateData();
_variant_t varIndex;
_variant_t varVal;
try
{
m_pRs->AddNew();
varIndex.vt=VT_I4;
varIndex.lVal=1;
varVal.vt=VT_BSTR;
varVal.bstrVal=m_strDlgTitle.AllocSysString();
m_pRs->Fields->GetItem(varIndex)->PutValue(varVal);
varIndex.lVal=2;
::SysFreeString(varVal.bstrVal);
varVal.bstrVal=m_strDlgDescription.AllocSysString();
m_pRs->Fields->GetItem(&varIndex)->PutValue(&varVal);
::SysFreeString(varVal.bstrVal);
vtMissing;
m_pRs->Update(vtMissing,vtMissing);
RefreshBoundData();
}
catch(_com_error &e)
{
AfxMessageBox(e.Description());
}
::SysFreeString(varVal.bstrVal);
the code works fine (the new data shows up in the access DB)
the problem is :
when i call RefreshBoundData the dialog refreshes only the textox that shows the ID (autonumber) while other fields (text,memo) appear empty ..
the code of RefreshBoundData is :
void CRsCgDlgCat::RefreshBoundData()
{
if (adFldOK == lIDStatus)
m_lDlgID = m_lID;
else
m_lDlgID = 0;
if (adFldOK == lTitleStatus)
m_strDlgTitle = m_wszTitle;
else
m_strDlgTitle = _T("");
if (adFldOK == lDescriptionStatus)
m_strDlgDescription = m_wszDescription;
else
m_strDlgDescription = _T("");
UpdateData(FALSE);
}
i found that the problem is : lTitleStatus,lDescriptionStatus are equal to 3 (means that they are nulls !!!)
can u help ?
please send any Qs if my post is not clear
|
|
|
|