|
|
*ahem*
thanks. stupid mistake. it was only large enough for one line, not both. haha. sorry!!!
|
|
|
|
|
Assuming a declaration of a character buffer:
char MyBuffer[10];
Will the following two statements produce the same results?
MyBuffer[5] = "x";
char* pMyBuffer = &MyBuffer;
pMyBuffer = pMyBuffer + 5;
*pMyBuffer = "x";
Thanks for your help,
|
|
|
|
|
I think you meant 'x' and not "x" . Also, you're assuming the size of a character is 1 byte (which is true for non Unicode/MBCS systems). Finally, I would initialize pMyBufferwrite like this (just to be explicit):
char* pMyBuffer = & (MyBuffer[0]);
...
Apart from this, yes.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
Also, you're assuming the size of a character is 1 byte (which is true for non Unicode/MBCS systems).
AFAIK a char in C/C++ is always one byte in size. And his example uses char s not TCHAR s.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Alvaro Mendez wrote:
AFAIK a char in C/C++ is always one byte in size.
Good point!
I've been spending (way) too much time moving between CString s, char* and XMLCh in my (Unicode) app. My mind is in a fog (i.e. more than usual).
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
I've been spending (way) too much time moving between CStrings, char* and XMLCh in my (Unicode) app.
Perfectly understandable. I don't remember the last time I used char in an MFC app. It's practically extinct.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Not the way you have them. Here's how:
char MyBuffer[10];
// 1
MyBuffer[5] = 'x';
// 2
char* pMyBuffer = MyBuffer;
pMyBuffer = pMyBuffer + 5;
*pMyBuffer = 'x';
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Thank you! You guys are a great help.
|
|
|
|
|
How can I use the Setup API functions with a INF_STYLE_OLDNT inf file to cause the PnP Manager to kick in? If I need to use a INF_STYLE_WIN4 inf file, what are the key Setup API functions?
|
|
|
|
|
I have a static filter using something like this:
TCHAR* tcFilter = _T("Word Document\0*.DOC\0Excel Document\0*.XLS\0");
What I really need is a dynamic filter where I can remove or add file types to it.
TCHAR* tcFilter = NULL;
if (IsWordInstalled())
etc.
Any suggestions on how I can do this? That '\0' delimiter really throws me for a loop.
"It is better to remain silent and be thought a fool than to open one's mouth and remove all doubt." - Abraham Lincoln
|
|
|
|
|
I think you'll need to use std::string to handle the embedded '\0' characters.
Otherwise, you'll have to get tricky with the memcpy() function.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Correct.
One solution is memcpy().
Kuphryn
|
|
|
|
|
This works for me:
CString strFilter;
strFilter += ...
strFilter += (TCHAR)'\0';
dlgFile.m_ofn.lpstrFilter = strFilter;
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Would that handle multiple filters separated by '\0'?
"It is better to remain silent and be thought a fool than to open one's mouth and remove all doubt." - Abraham Lincoln
|
|
|
|
|
Jason Henderson wrote:
Would that handle multiple filters separated by '\0'?
Yes. You only need the \0\0 at the end from memory. Anyway this is how I do it in ED (see sig) to dynamically build the file types list.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
How about a little function that you can call for that:
int AddToFilter(TCHAR* szFilter, int nSize, LPCTSTR szDescription, LPCTSTR szExtension)
{
ASSERT(szFilter);
ASSERT(szDescription);
ASSERT(szExtension);
_tcscpy(&szFilter[nSize], szDescription);
int nLenDesc = _tcslen(szDescription);
_tcscpy(&szFilter[nSize + nLenDesc + sizeof(TCHAR)], szExtension);
int nLenExt = _tcslen(szExtension);
return nSize + nLenDesc + nLenExt + (sizeof(TCHAR) * 2);
}
Then you can use it like this:
TCHAR szFilter[300] = _T("");
int nSize = 0;
if (IsWordInstalled())
nSize = AddToFilter(szFilter, nSize, _T("Word"), _T("*.doc"));
if (IsExcelInstalled())
nSize = AddToFilter(szFilter, nSize, _T("Excel"), _T("*.xls"));
AddToFilter(szFilter, nSize, _T("All Files"), _T("*.*"));
I haven't tested (or even compiled) this, but hopefully it's close enough.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Whoa, thanks. I didn't expect you to write the code for me, but I'll give it a shot.
"It is better to remain silent and be thought a fool than to open one's mouth and remove all doubt." - Abraham Lincoln
|
|
|
|
|
I would say you must do this dynamically with raw tchar data - and you must terminate it with \0\0 BTW. Make sure tcFilter is declared with space to spare, find the length by searching for "\0\0",
J.
----------------------------
|
|
|
|
|
Hi all,
I am developing a dialog based application in VC6.0
I have four bitmap resources on main dialog window.
I have disabled them on startup by calling ShowWindow(FALSE) and enabling them on runtime, by calling ShowWindow(TRUE)
They are appearing in a sequence because I have enabled them one by one.
I want to enable them all parallel rather then in sequential manner.
Please any body knows how to do that.
Regards,
The Phantom.
|
|
|
|
|
Maybe using LockWindowUpdate /UnlockWindowUpdate ?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
How can I make an animated gif to AVI for VC?
Thank you
|
|
|
|
|
i'm using visual c++.net and sometimes when i'm just typing in code, the whole C++ development environment just crashes. A DOS command box appears onscreen with the word 'mscordump' on it... and the development environment just closes itself. This is very strange - does anyone know what could cause this?
|
|
|
|
|
pffdaddy wrote:
A DOS command box appears onscreen with the word 'mscordump' on it
Processor overheating?
Memory-timing too fast for your (possibly crappy) ram-chips?
Bad sectors on your harddisk in some essential DLLs or your Pagefile?
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
i need lots images for our new project, the images are in size of 16x16 and 32x32 pixels.
format can be bitmap, icon, cursor or others.
do you know any web sites from which i can download those images ?
thanks for any links.
includeh10
|
|
|
|