|
You are painting in the window and then calling the base class OnEraseBkgnd() which will of course ERASE everything you just painted... Yes?
This i am guessing is what is making you sad
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
hi i am using MSWinSock Activex in my project to Create a Simple TCP connection through a server.
for this purpose i have to Send an Message to that Server. My message should Contain Some NULL char char(0) in it.
for example my message should be something like this : HI***This is Ehsan******Accept my request (here * means char(0) or NULL char )
MSWinSock Uses this Syntax to send a Message : void CMSWinsockControl::SendData(const VARIANT& data)
this means that i have to Save my message in a VARIANT type variable and then Send it with this function.
in VARIANT i can use BSTR to store my message in VARIANT but as u know Char(0) means the end of a String So i need to Store my message in a Different way in VARIANT variable.
one way is to store a Char[] (an array of char) in a Variant !! is it Possible ??
Thankx a lot
|
|
|
|
|
As a BSTR includes the size of the string (rather than relying on null termination), it
should exactly suit your needs.
Just a quick look at CComBSTR:
CComBSTR( );
CComBSTR( int nSize );
CComBSTR( int nSize, LPCOLESTR sz );
CComBSTR( int nSize, LPCSTR sz );
nSize
[in] The number of characters to copy from sz.
sz
[in] A string to copy. The Unicode version specifies an LPCOLESTR; the ANSI version specifies an LPCSTR. Only nSize characters will be copied. The default value is NULL.
So that *should* sort out your problem.
Iain.
|
|
|
|
|
why don't yopu try the void
*memset( void *dest, int c, size_t count );
function which inits the memory of a string with a given char on a certain length; or
char *_strset( char *string, int c );
char *_strnset( char *string, int c, size_t count );
#include <string.h>
#include <stdio.h>
void main( void )
{
char string[15] = "This is a test";
/* Set not more than 4 characters of string to be *'s */
printf( "Before: %s\n", string );
_strnset( string, '*', 4 );
printf( "After: %s\n", string );
}
Output
Before: This is a test
After: **** is a test
I hope this helped.
gabby
|
|
|
|
|
I found a lot of ebook on the web. I was very intrested. I want to make a ebook like this by myself.But what should I do and How can I do this? I want to use C++,Visual C++ 6.0. Any ideas or examples?
Thank you all.
Alick
|
|
|
|
|
Alick Xiong wrote:
I want to make a ebook like this by myself.But what should I do and How can I do this?
http://www.ebookswriter.com/
http://www.tomdownload.com/home_education/e_books_literature/ebookswriter.htm
http://www.axeman.co.nz/eBook_generator.html
http://www.webpronews.com/ebusiness/smallbusiness/wpn-2-20000514MakeYourOwnEbook.html
I do not know how to do it programmatically.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I need a CCamera class which indicate the camera in Directx.
Thanks~~
buaa_chenx@hotmail.com
|
|
|
|
|
Hi
I would like to know how to log the date and time and retrieve them at later stage.
Someone books to attend a conference i want to log the exact time and date the booking whas made.
Do i use the time class and just somehow write these to a file or how do i do that.
many thanks
Education begins a gentleman,
conversation completes him
|
|
|
|
|
CTime class.
You can get the lot.
I usely get the year, month ... in integer and set them via the Format function of CString in a CString (like: yyyy/mm/dd hh/mimi/ss)
Have Fun,
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix
|
|
|
|
|
<font style="color:blue;">#include</font> <ofstream>
<font style="color:blue;">void </font>LogMessage (LPCTSTR strMessage) {
std::ostream OutputFile(<font style="color:purple;">"C:\\MyFolder\\My_log_file.txt"</font>);
CTime CurrentTime = CTime::GetCurrentTime();
CString TimeMrk = <font style="color:purple;">"["</font> + CurrentTime.Format(<font style="color:purple;">"%H:%M:%S"</font>) + <font style="color:purple;">"] "</font>;
OutputFile << TimeMrk << strMessage; <font style="color:green;">
}
TOXCCT >>> GEII power
|
|
|
|
|
Ok, this isn't a programming question but...
Has anybody else out there had the problem of VS.NET hanging when you exit. The UI vanishes but devnet.exe remains in the background running. Practically everyone on this project has this problem.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi Dear...
I'm trying to bind DB-Grid & ADO..please help Me..
I'm using MS-DB Grid Control & MS ADO Control ActiveX.using vc+6.0. I want to bind ADO & Grid
Thanks for help Advance..
what I'm Doing is:
int CDBGridTestDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
m_Ado.Create (NULL,WS_VISIBLE|WS_CHILD,CRect(0,0,100,20),this,IDC_ADODC1);
m_Ado.SetConnectionString("Provider=MSDASQL.1;Persist Security Info=False;Data Source=FileCheck");
//m_Ado.SetCommandType(2);
m_Ado.SetRecordSource("Select * From TBL_ITEM_TYPE");
m_Ado.Refresh();
m_Grid.Create(NULL,WS_VISIBLE|WS_CHILD,CRect(20,20,300,200),this,IDC_DBGRID1);
LPUNKNOWN pCursor=m_Ado.GetDSCCursor();
m_Grid.SetDataSource(pCursor);
m_Grid.BindProperty(0x9, &m_Ado);
m_Grid.Refresh();
return 0;
}
bye
---Sumit Kapoor---
|
|
|
|
|
Hi
As usual i recd. following message on my build output window
How to find the point of the memory leak and how to overcome it.
Thanks a lot for any suggestion.
Sandeep
Detected memory leaks! <br />
Dumping objects -><br />
strcore.cpp(118) : {1639} normal block at 0x0063B6B0, 181 bytes long.<br />
Data: < ODBC> 01 00 00 00 A8 00 00 00 A8 00 00 00 4F 44 42 43 <br />
D:\Documents and Settings\erc\Desktop\Pattern\DBManager.cpp(32) : {1633} client block at 0x0063B900, subtype 0, 100 bytes long.<br />
a CDatabase object at $0063B900, 100 bytes long<br />
D:\Documents and Settings\erc\Desktop\Pattern\PatternDoc.cpp(508) : {1535} client block at 0x0063A180, subtype 0, 88 bytes long.<br />
a CObject object at $0063A180, 88 bytes long
Leave your mark wherever you go
|
|
|
|
|
You usually find the memory leak by simply clicking on the line reported say
strcore.cpp(118)
But, if that file resides out side your project, as strcore.cpp does (its part of MFC) it wont work.
The second leak should "D:\Documents and Settings\erc\Desktop\Pattern\DBManager.cpp(32) "
Double click it and it will take you to where it was allocated.
As for the first, you have a leak via a CString somewhere.
|
|
|
|
|
ah you beat me to it... gotta type a little faster next time
|
|
|
|
|
Well they gets two answers to their Q not just one - effeciant this CP message board eh.
|
|
|
|
|
one way is dubble clicking on the line
the other reading it..
first line says:
strcore.cpp(118) etc etc etc
says that the mem was allocated on line 118 of the strcore.cpp file...(but never deallocated)
in your DBManager.cpp file line 32 you allocate memory that wasn^t deallocated
same for PatternDoc.cpp line 508.
as for in which situations that occurs... Debug!! put breakpoints and read carefull your new and delete statements!
Regards,
Davy
|
|
|
|
|
Thanks i will check it and will come up back
Leave your mark wherever you go
|
|
|
|
|
Hi,
this is my problem.
I have an MFC diaog based application with multiple edit boxes.
What I need to do is to automatically select all the text inside a box when clicking on it.
That's just what happens on Explorer address bar...
I've tried writing inside each OnSetfocusEdit function
m_edit.SetSel(0,-1);
m_edit.SetFocus();
I also tried to write only the line
m_edit.SetSel(0,-1);
but it didn't work.
If I put the same 2 lines in a button click the operation succeeds.
Why is this?
Can anyone help me?
Thank you in advance,
Marco.
|
|
|
|
|
the SetFocus call is not necessary anymore in the OnSetFocus.. functions, since it allready is getting the focus.
That`s probably the source of all evil...
Regards,
Davy
|
|
|
|
|
Already done, but it doesn't work...
Any other suggestion?
Thanks,
Marco.
|
|
|
|
|
Hi Marco,
Try the PreTranslateMessage override, e.g. for an IE address bar type behaviour...
BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
BOOL bEatMe = FALSE;
if (pMsg && pMsg->message == WM_LBUTTONDOWN)
{
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT1);
if (pEdit && pEdit->GetSafeHwnd() && pMsg->hwnd == pEdit->GetSafeHwnd())
{
CWnd* pPrevFocus = pEdit->SetFocus();
if (pPrevFocus == pEdit)
{
}
else
{
bEatMe = TRUE;
pEdit->SetSel(0,-1, TRUE);
}
}
}
return (bEatMe) ? TRUE:CDialog::PreTranslateMessage(pMsg);
}
Hope this helps,
Andy
|
|
|
|
|
;););););););););););););););)
Thanks a lot !!!!!! Now it WORKS !!!!!!
Marco.
;););););););););););););););)
|
|
|
|
|
If the clicking of an edit control selects all of the text contained within it, how is a person able to make a correction? Normally, a double-click of an edit control selects all of the text contained within it, and a single-click merely places the edit cursor at some point within the control. Doesn't this sound counterintuitive?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I think you'd want this behavior only if the user is likely to almost always replace the existing text. The user can still modify the text by pressing "End", "Home" or the arrow keys to first clear the selection, although this involves an extra keystroke.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|