|
Currently I am using an overloaded function that uses a void pointer and the length of the pointer. However I am having an issue as the output cannot contain nulls and in a few cases it does. I need to strip/replace the nulls in the pointer so they don't show up in the output. I have included a brief snipit to give you an idea of what I am trying to do.
Current Code
note - openfile is CFile object
---------------------------------
FunctionX(void* buf, ASInt32 bufLen)
{
DURING
openfile.Write(buf, bufLen);
}
|
|
|
|
|
|
|
Your response was not entirely helpful or appreciated. I am not even sure what you meant by it. If you are trying to imply that I am missing something obvious please enlighten me.
I have had a crash course in C++ over the last 2 weeks and I believe the solution to be simple. I simply need to remove/replace on the nulls and output the remaining text to a file. I have no idea how to accomplish this from C++ when I am starting with a void pointer.
|
|
|
|
|
Brian Farrell wrote:
Your response was not entirely helpful...
Agreed. That attitude seems to be a common post from him/her.
Anyway, you could have something like:
FunctionX(void* buf, ASInt32 bufLen)
{
LPBYTE lp = (LPBYTE) buf,
b;
b = new BYTE[bufLen];
for (int y = 0, x = 0; y < bufLen; y++)
{
if ('\0' != *(lp + y))
b[x++] = *(lp + y);
}
openfile.Write(b, x);
delete [] b;
}
|
|
|
|
|
Thats exactly what I am looking for. Thank you.
|
|
|
|
|
Hello,
Just wondering if one of these ways is better than the other? And why?
char sTest[256];
lstrcpy(sTest,"testing");
CString strTest = sTest;
or
CString strTest;
strTest.Format("%s",sTest);
Thanks,
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Huh ?
CString strText("Testing");
or did I missed something ?
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
You have not missed anything That guy is clearly a nutjob.
|
|
|
|
|
Thanks, your post really helps. I love it when people are nice.
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
No problem. Stupid question deserves a stupid reply
|
|
|
|
|
Well, we'd rather have the stupid people making the stupid replies shut the f*ck up. Then once they become smart enough to realize that acting like an a**hole is stupid, their contributions will be more than welcome to those who need help.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
I was just trying to make the question simple..
I have a structure that contains chars, int's etc...
I send the structure across a socket.. when it's received on the other side I I want to put the char (from the structure) into a CString. so my question was is it ok to to do a CString strTest = sTest or should I use the format function provided by CString?
I guess I just tried to over simplify the question...
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
The following two lines are equivalent:
<br />
std::string s1("one");
std::string s2 = "two";
If I recall correctly, there is a standard "short-cut" that compilers can (must?) take to make example 2 above work like example 1. In other words, declaration with assignment is optimised to a constructor provided that an appropriatly overloaded constructor exists. If no constructor, you get a compiler error.
Either would likely be faster then default constructor followed by Format() for two reasons. First, it's two steps. Second, Format() is probably slow with all that string parsing. Of course, YMMV.
Brad
|
|
|
|
|
will #2 generate a copy constructor ? or will it be converted into constructor ?
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
|
Format() in this case is the worse choice of the two, because it's a bit harder to read. With the plain assignment, it's clearer what the code is doing. Format() also will run a bit slower because it has to parse the format string and the other arguments in order to calculate the length of the resulting string, although the slowness is nothing a person would even notice.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Ericahist updated Aug 30!
|
|
|
|
|
M. Dunn has the right response. If you are just assigning a simple string of characters to the CString object, using the assignment operator is the easiest. Employ the use of Format() only when variables/values need to be substituted.
|
|
|
|
|
Hello,
does anyone know how to customize the look of the CListCtrl RectTracker? I want it to look like the Windows XP Explorer RectTracker and still reuse a max of stuff already implemented in the standard RectTracker provided by CListCtrl (like dynamic selection and partial invalidates)?
Regards,
Nicolas
|
|
|
|
|
In MSDN I’ve found article Q179221 where it is described how to do it using Explorer Policies
(keys NoRun, NoFileUrl, NoDrives, etc under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer). But it is not prevent, for example, of viewing end executing files in the frame: .
Is anybody ever met with such a task?
|
|
|
|
|
>Is anybody ever met with such a task?
Yeah, pretty simple. Just embed webbrowser in your own application,
OnNavigate(Navigate2) check url and cancel navigation if it is local drive.
Brian
|
|
|
|
|
This one is probably asked before, I saw some solutions but none of them seem to work.
How do you make a text static transparent?
I've got this:
CStatic m_ctrlLabel;<br />
m_ctrlLabel.Create(_T("TEST"), WS_VISIBLE|WS_CHILD, CRect(0,0,32,16), pParent, 0);<br />
m_ctrlLabel.ModifyStyleEx(0,WS_EX_TRANSPARENT);
But this doesn't work. Did I forget something?
btw. I'm not planning to subclass the control.
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
Control with WS_EX_TRANSPARENT has the background of its parent. You probably put static control on i.e tab control which lies on dialog. But the parent of static control is still this dialog. To correct such situation override CDialog::OnCtlColor. Type ON_WM_CTLCOLOR() in MESSAGE_MAP. Then
change the background color of your static control as you wish (i.e set it as those tab control):
HBRUSH CTTSDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor == CTLCOLOR_STATIC && pWnd->GetDlgCtrlID() != IDC_DEFAULT_CHECK)
{
CWnd *TabCtrl = GetDlgItem(IDC_LANG_TAB);
CWnd *Ctrl = GetDlgItem(pWnd->GetDlgCtrlID());
if (Ctrl)
{
CRect Rect; Ctrl->GetWindowRect(&Rect);
TabCtrl->ScreenToClient(&Rect);
COLORREF Clr = TabCtrl->GetDC()->GetPixel(Rect.left-1, Rect.top-1);
DeleteObject(hbr);
hbr = CreateSolidBrush(Clr);
pDC->SetBkColor(Clr);
}
}
return hbr;
}
|
|
|
|
|
MSDN:
WS_EX_TRANSPARENT Specifies that a window created with this style is to be transparent. That is, any windows that are beneath the window are not obscured by the window. A window created with this style receives WM_PAINT messages only after all sibling windows beneath it have been updated.
In other words all WS_EX_TRANSPARENT does is changes the way WM_PAINT is sent. To make static transparent You need to override OnCtlColor and set correct dc mode.
HBRUSH CMyFormView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if (m_nWhich==ID_MY_STATIC )
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
}
}
|
|
|
|
|
I would like to know if there is a way to disable the enter key from being used in my app. It seems that every time the enter key is pressed, it closes a dialog in my app.
Thank you.
Jimmy
Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
|
|
|
|