|
MFC framework does not send ON_CBN_EDITCHANGE message if the combobox contains the CBS_DROPDOWNLIST style.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_MFC_CComboBox.asp
Kuphryn
|
|
|
|
|
Thanks! It works!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
I read some simple char s (1 byte wide) from a file and want to build a string, based on this simple char s.
Sample:
Read 'B'
Read 'ü'
Read 'r'
Read 'o'
--> string: "Büro"
I use the following code:
while (TRUE)
{
char c = 0;
DWORD dwReadBytes;
if (!ReadFile(m_hFile, &c, sizeof(char), &dwReadBytes, NULL) ||
dwReadBytes != (DWORD) sizeof(char))
{
ErrorMessage(_T("Unerwartetes Dateiende (EOF) in Zeile %d."), m_nCurrentLine);
return FALSE;
}
if (c == '\n')
{
break;
}
str += CString((TCHAR) c);
}
The problem is the line str += CString((TCHAR) c); .
My system (PocketPC) works with UNICODE and so I have to convert the readed char to a UNICODE char .
I have used TCHAR that I can use the source code on both systems (UNICODE & non UNICODE).
So, the problem is now that when I read some chars like ö. ä, ü, ... the conersion result is a "?" .
So, when I should read the string "Büro" the result is "B?ro" . It look like, that the conversion failed!
How can I fix that?
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
check out the USES_CONVERSION; macro in msdn and W2A() and A2W()
"even if my world is weird it's my world" biz stuff about me
|
|
|
|
|
lauren wrote:
check out the USES_CONVERSION; macro in msdn and W2A() and A2W()
...but how to use with a single TCHAR ? This macros uses strings (more than a single char) and no single chars.
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Fortunately, you don't speak Spanish. You wouldn't use Buro like that..
How low can you go ? (MS rant)
|
|
|
|
|
The applicatio is for german user...
"Büro" is the german word for "Office"...
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Because casting does not convert between character sets. What I'd do is read the data into a buffer (keeping it as MBCS), zero-terminate it, then put it in a CString which will convert it for you properly.
--Mike--
"I'd rather you just give me a fish today, because even if you teach me how to fish, I won't do it. I'm lazy." -- Nish
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Thanks Mike!
I have seen...
It was a very silly bug...
*rrrhhh - Sometimes I am so stupid*
Thank you very very very much for your help on my stupid questions...
I hope I can invite you to one or some more beer when I will travel to Los Angeles anytime in the next years!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
I am trying to capture a bitmap or an icon from a .bmp or .ico file selected by a user from a standard CFileDialog dialog.
LoadImage() always fails (returns 0 and hBitmap or hIcon are NULL).
CString strAppPath;<br />
CSString strImagesDirectory;<br />
CString pathName;<br />
CString fileName;<br />
CString extName;<br />
HICON hIcon;<br />
HBITMAP hBitmap;<br />
<br />
CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY, "Bitmap(*.BMP)|*.BMP|Icon(*.ico) <br />
*.ico||", this);<br />
if( dlg.DoModal() == IDOK )<br />
{<br />
pathName = dlg.GetPathName();<br />
fileName = dlg.GetFileTitle();<br />
extName = dlg.GetFileExt();<br />
<br />
if (extName == "ico" || extName == "ICO")<br />
{ <br />
hIcon = (HICON)::LoadImage( NULL, pathName, IMAGE_ICON, 0, 0, <br />
LR_LOADFROMFILE|LR_DEFAULTCOLOR ); <br />
if (hIcon)<br />
SetIcon(hIcon, TRUE);<br />
}<br />
else<br />
{<br />
hBitmap = (HBITMAP)::LoadImage( NULL, "C:\\HAPPY.BMP", IMAGE_BITMAP, 0, 0, <br />
LR_LOADFROMFILE|LR_CREATEDIBSECTION);<br />
if (hBitmap)<br />
bmpImage->Attach(hBitmap);<br />
}<br />
<br />
}
I have tried a number of things with the second parameter of the LoadImage() call -- hard coded path to the file, path as captured by the CFileDialog, image files in the root directory and located in a variety of other locations (including the directory of the working project). Nothing works. I have searched the documentation and what I have should work.
I am working on Windows 2000 Professional and in Visual Studio .NET but in unmanaged C++ code.
Anyone have any idea whta I am doing wrong?
Sydney Liles
Software Engineer
|
|
|
|
|
The first parameter should be the instance of your module. Passing NULL instead is only for OEM images.
How low can you go ? (MS rant)
|
|
|
|
|
This is one of the things I have tried. I tried it again after I got your response. No luck.
I changed the code to look like this:
CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY, "Bitmap(*.BMP)|*.BMP|Icon(*.ico)<br />
|*.ico||", this);<br />
if( dlg.DoModal() == IDOK )<br />
{<br />
pathName = dlg.GetPathName();<br />
BYTE FileBuffer[10240] = "";<br />
fileName = dlg.GetFileTitle();<br />
extName = dlg.GetFileExt();<br />
<br />
HINSTANCE hInst = AfxGetInstanceHandle();<br />
<br />
if (extName == "ico" || extName == "ICO")<br />
{ <br />
hIcon = (HICON)::LoadImage(hInst, pathName, IMAGE_ICON, 0, 0, <br />
LR_LOADFROMFILE|LR_DEFAULTCOLOR); <br />
if (hIcon)<br />
SetIcon(hIcon, TRUE);<br />
}<br />
else<br />
{<br />
hBitmap=(HBITMAP)::LoadImage(hInst, "C:\\HAPPY.BMP", IMAGE_BITMAP, 0, 0, <br />
LR_LOADFROMFILE|LR_CREATEDIBSECTION);<br />
if (hBitmap)<br />
bmpImage->Attach(hBitmap);<br />
}<br />
<br />
}
I know I am getting a valid HINSTANCE.
Any other suggestions?
BTW -- I really do appreciate the help.
Sydney Liles
Software Engineer
|
|
|
|
|
Code from MSDN[^].
How low can you go ? (MS rant)
|
|
|
|
|
Boy, I sound like my children (no, that won't work)
I did try that -- This is one of the documents I found that discusses LoadImage(). The problem remains the same. When I add this code to my own, then the LoadImage() call in the LoadBitmapFromBMPFile() fails.
BOOL LoadBitmapFromBMPFile( LPTSTR szFileName, HBITMAP *phBitmap,<br />
HPALETTE *phPalette )<br />
{<br />
<br />
BITMAP bm;<br />
<br />
*phBitmap = NULL;<br />
*phPalette = NULL;<br />
<br />
<big>*phBitmap = (HBITMAP)LoadImage( NULL, szFileName, IMAGE_BITMAP, 0, 0,<br />
LR_CREATEDIBSECTION | LR_DEFAULTSIZE | LR_LOADFROMFILE );</big> <br />
if( *phBitmap == NULL )<br />
return FALSE;<br />
I think there is something going on with LoadImage() itself. I thought that the .bmp files I was using to test might be the problem because they are very old and have not been updated. I got a .bmp with lots more information stored in the properties and it does not work either.
The only thing I can think of is that LoadImage() fails on Win2K. I read a Microsoft Knowledge Base article to this effect http://support.microsoft.com/default.aspx?scid=kb;en-us;Q329092. I do not have access to a Win9x machine with Visual Studio installed to test this theory.
Thanks though.
Sydney Liles
Software Engineer
|
|
|
|
|
What does GetLastError return after you call this function and it fails?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Funny you should ask.
I just added a call to GetLastError() a few minutes ago and realized that I had created a CFile (to get size information), opened it, read the contents of the .bmp into a buffer(in an attempt to get LoadImage() to work) and then closed it after I attempted to call LoadImage() -- GetLastError() returned 32 (ERROR_SHARING_VIOLATION). I moved the CFile::Close() to before the call to LoadImage() and now all is well.
It was a dumb thing to over look. Wish I had tried the GetLastError() sooner. Oh well.
Thanks for all of the help.
Sydney Liles
Software Engineer
|
|
|
|
|
Hi
the last few weeks I modified some files in my Platform-SDK directory, resulting in linker errors and missing files
Now I have uninstalled the latest Platform SDK completely and reinstalled it again, but I still keep getting this error (German):
C:\PROGRAMME\MICROSOFT SDK\LIB\LIBC.lib : fatal error LNK1112: Computer-Typ "IA64" fuer Modul steht in Konflikt mit dem Ziel-Computer-Typ "IX86"
This seems to me to be a conflict between 32bit and 64bit libraries. My project is build for 32bit platforms.
But the first library path the compiler should use is defined as C:\PROGRAMME\MICROSOFT SDK\LIB\ , that's why I don't know how the error can occur.
thanks in advance
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Try to find this path in the registry, and modify it or kill it.
How low can you go ? (MS rant)
|
|
|
|
|
I did both, but nothing helped
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hello,
I want to ask how to store a String in 2-D array foramt?
e.g.
abc[0][0]="A";
abc[0][1]="AA";
abc[0][2]="AAA";
......
....
..
abc[n][n]="AAAAAAAAAAAAAAA";
THX!!!
I am not using MFC, just the console mode!!!
I think it for a long time!!!
|
|
|
|
|
If your 2-D array will simply hold literal strings, like in your example, declare it as a 2-D array of pointers to characters, like this:
char* abc[N][N];
This assumes N is a predefined constant value.
Regards,
Alvaro
Insanity: doing the same thing over and over again and expecting different results. - Albert Einstein
|
|
|
|
|
I am developing for a Windows CE device in which there is a bug where files that are divisble by 2048 aren't copiable from the permanent storage to the volatile storage. At this moment I have been just checking to see if the exe's and dll's are divisible by 2048 and if so add some characters to the end of the file. Is this a safe practice or should I be doing something else.
I have tried putting an int padding[] = {0, 1,..., etc} in the file but it seems the file doesn't change in size; which, I could only assume is the optimizing compiler removing it.
Cheers,
Clint
|
|
|
|
|
I'm sure that there is a linker setting for this, but I can't remember it at all...
And, for the padding, for the compiler optimizer do not remove it, try do something, like reading all the array in a for loop...
Q261186 - Computer Randomly Plays Classical Music
|
|
|
|
|
I was trying to get Googles webpage by using Winsock. But the real problem is I am behind Firewall (Microsoft ISA). As far as the Winsock is concerned getting webpage within the Firewalll is not difficult. But when I try to access behind the Firewall the Server won't allow me anymore.
Please anyone can help regarding how can I access a webserver behind firewall by using Winsock. How can I use or implement Proxy support in my program.
Dammy More
|
|
|
|
|
You should check out the relavent RFC on supporting a HTTP Proxy. For an example of winsock programming which works thro a HTTP proxy, check out my CDDB class at http://www.naughter.com/mfccddb.html
|
|
|
|