|
WOOHO THANK U SOOOO MUCH!
Kuniva
--------------------------------------------
|
|
|
|
|
A char variable in Java is 2 bytes. A char in variable C/C++ is one byte. This is related to the character encodings the languages use. Unicode characters are 2 bytes each.
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
A CHAR is 8 bits SIGNED.
If you need to handle binary data, use UNSIGNED CHAR.
|
|
|
|
|
http://www.codeproject.com/string/CPPStringGuide1.asp -Give s an comprehensive overview of strings ,character
|
|
|
|
|
There's no iterator for stack ( as far as MSDN is concerned )
Is there a way to traverse the stack ?
Thanks.
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
One solution is a while loop and check the status of the stack via empty().
Kuphryn
|
|
|
|
|
Maximilien wrote:
There's no iterator for stack
That's right. Because you're only allowed to look at the top element.
If you *must* use a stack (rather than a list or deque) and *must* traverse it, you can always derive from std::stack and then access the underlying data container (yuk )
You should save yourself and your company years of grief by shooting yourself through the head immediately. Believe me, in the long run it'll turn out better for everyone. - Tyto (at arstechnica)
Awasu 1.0[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
ok.. i am getting closer and closer to almost having something that almost works..
i have an example of a function that interacts with vb, and it modifies a variable that comes in by making it backwards before returning.. all i am trying to do is be able to set the value of the variable before returning.. the variable is of type BSTR, and i am getting nowhere.. here is an example of modifying the string which works:
void __stdcall FindBankName(LPSTR strFilename, LPSTR strRoutingNumber, BSTR a)
{
int i, iLen;
BSTR b;
LPSTR pA, pB;
iLen = lstrlen( (LPCSTR) a );
b = SysAllocStringLen( NULL, iLen );
pA = (LPSTR)a;
pB = (LPSTR)b + iLen -1;
for ( i = 0; i < iLen; i++ )
*pB-- = *pA++;
pA = (LPSTR)a;
pB = (LPSTR)b;
for ( i = 0; i < iLen; i++ )
*pA++ = *pB++;
SysFreeString( b );
} here is an example of one of the many many unsuccessful tries which doesn't work:
void __stdcall FindBankName(LPSTR strFilename, LPSTR strRoutingNumber, BSTR a)
{
a = SysAllocString ( "Woop Howdi Bob!" );
}
my main purpose here is to be able to set a variable of type BSTR equal to a character array i have..
like:
char szBuffer[60];
thanks a ton fer everyones help..
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
void __stdcall FindBankName(LPSTR strFilename, LPSTR strRoutingNumber, BSTR a){
a = SysAllocString ( "Woop Howdi Bob!" );
}
First, it's wrong and going to leak memory.
void __stdcall FindBankName(LPSTR strFilename, LPSTR strRoutingNumber, BSTR *a)
{
*a = SysAllocString ( "Woop Howdi Bob!" );
}
|
|
|
|
|
I am not sure, but according to VC++ source codes, BSTR is actualy an LPWSTR which is by turn a pointer to WCHAR or wide charater type that's used in UNICODE. That means you may use wide charater functions to set its value.
For example, to set the BSTR a paramter that you have in your code we may do this:
int len = wcslen(a);
if(len >= wcslen(L"Testing"))
wcscpy(a, L"Testing");
This code is to change an existing BSTR variable but if you are making new one then SysAllocString() should be used.
if your string is ANSI then you must convert it first to UNICODE. If you are using VC++7 then the easiest way is to use CStringW, for e.g.:
char buff[] = "Test";
CStringW strw(buff);
wcscpy(a, strw);
Otherwise you should use MultiByteToWideChar() to convert.
|
|
|
|
|
Hi all. I've created a list view with a bunch of columns. My problem is that when the view comes up, the columns aren't expanded so you can see and/or read what they are. Here's how I'm inserting the columns:
pcol.mask = LVCF_TEXT;
pcol.fmt = LVCFMT_CENTER;
pcol.cx = strlen(column_header[index]) * CHAR_PIXEL_WIDTH;
pcol.pszText = column_header[index];
pcol.cchTextMax = COLUMN_WIDTH;
ListView_InsertColumn(hListView,0,&pcol);
And here is how I am inserting into the list view:
// Insert the name into the list
lvItemList.mask = LVIF_TEXT;
lvItemList.iItem = itemIndex;
lvItemList.iSubItem = 0;
lvItemList.pszText = app;
lvItemList.cchTextMax = 128;
// Insert the item into the list
ListView_InsertItem(hListView,&lvItemList);
Nothing fancy going on here just using the normal LV_ITEM and LVITEM structures, and there's no extra funny stuff going into the LPARAM. So my question is what am I doing wrong here? I thought that by specifying the pcol.cx value to the width that I wanted, the width would be automatically setup for me, but that does not seem to be the case.
Any comments are appreciated.
Thanks!
|
|
|
|
|
i've never used that method of creating lists.. but ive used bunches of them and have always specified the widths of the columns.. here is how i do mine.. dunno if it'll help er not..
void CTopView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
ListView_SetExtendedListViewStyleEx(m_lstReportList.GetSafeHwnd(), NULL, LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
m_lstReportList.InsertColumn(0, "Form", LVCFMT_LEFT, 55);
m_lstReportList.InsertColumn(1, "Description", LVCFMT_LEFT, 238);
m_lstReportList.InsertColumn(2, "Period", LVCFMT_LEFT, 70);
}
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
dazinith wrote:
i've never used that method of creating lists.. but ive used bunches of them and have always specified the widths of the columns.. here is how i do mine.. dunno if it'll help er not..
Yeah, I've used that method in other applications and it works like a charm, but this application is written in Win32, not MFC.
thanks though.
Gotta work with what ya got in this case. Anyone else have a suggestions?
|
|
|
|
|
Actually,
Your replay gave me an idea. I checked the MFC code realizing that MFC is just an OO implementation of Win32, and Looked into the InsertColumn. That told me everything I needed to know, which happened to be me forgetting to add the LVCF_WIDTH to the item mask. that took care of my problem.
Thanks!
|
|
|
|
|
I don't know if I understand your question correctly. You want to set the width of the columns, so that the column text prefectly fits in? You could try GetTextExtentPoint32 to set the width directly to the width of your string.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I have a Formview class and I'm trying to display a message box when the user hits the X to close the form. If I do the processing in OnDestroy, the message box doesn't show up until after the form has closed.
How can I show this messagebox before the form goes away? I tried to catch a WM_CLOSE or WM_DESTROY message with PreTranslateMessage, but neither seem to work.
|
|
|
|
|
Interesting. Add some breakpoints in OnClose(). What gets called when you exit the program?
Kuphryn
|
|
|
|
|
|
ShellExecute ( NULL, "open", "control.exe", "Speech", NULL, SW_NORMAL ) ;
Desired result:
the user clicks on a button in dlg and Speech settings applet opens.
Problem is when SAPI 4 and 5 coexist on the same machine, two Speech icons are present and it doesn't open the applet
Any suggestions on how to approach this problem?
Thanks
Later, JoeSox www.joeswammi.com The only thing that saves us from the bureaucracy is inefficiency. An efficient bureaucracy is the greatest threat to liberty.
Eugene McCarthy
|
|
|
|
|
All,
I have a routine that writes to a USB device using the WriteFile API. The problem is, the USB device I'm writing to has a low battery, so when the WriteFile attemps to send data, it never gets a response back from the device.
The WriteFile gets its handle from an HID driver (Human Interface Device). I am calling the WriteFile with the LPOVERLAPPED structure (I need it for the ReadFile API, and you can't mix and match overlapped with non-overlapped). I would like to have the function return if it doesn't get a response back after X number of retires or X number of seconds...either or.
Any suggestions on how I can do this?
Regards,
Brigg Thorp
Software Engineer
Timex Corporation
|
|
|
|
|
What do you mean the function does not return? Given that the design is non-blocking via OVERLAPPED I/O, WriteFile() should return immediately.
Kuphryn
|
|
|
|
|
Since the USB device I'm writing to has a low battery, there is never a return message packet sent back to Windows from the WriteFile. So, the system just hangs in the WriteFile event forever. I put a breakpoint on the line after the WriteFile and it never gets there. Is there any way to cancel the IO after say 5 seconds of inactivity?
Regards,
Brigg Thorp
Software Engineer
Timex Corporation
|
|
|
|
|
Interesting. In terms of C++, one solution is be an exception try/catch.
Kuphryn
|
|
|
|
|
I have a CFormView and I need to capture the ESC key. The control the has the focus always receive the OnChar but the form never does. I don't want to use an Accelerator nor any code on the controls.
Any Ideas?
|
|
|
|
|
Just a guess:
Override PreTranslateMessage in your CFormView.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|