|
Jose Lamas Rios wrote:
Try defining UNICODE (with no leading underscore too). It seems like _UNICODE affects MFC headers, while UNICODE affects Win32 API headers
Right, I just noticed that that RegOpenKeyEx resolves to RegOpenKeyExW when UNICODE is defined, and not when _UNICODE is defined. I couldnt locate if UNICODE is automatically defined when _UNICODE is defined. So I now changed _UNICODE to UNICODE in the project settings, now tchar.h doesnt seem to know about UNICODE:
error C2664: 'RegOpenKeyExW' : cannot convert parameter 2 from 'char [512]' to 'const unsigned short *'
|
|
|
|
|
Ok, the problem goes away if I define both UNICODE as well as _UNICODE.
Is this how it is supposed to be?
|
|
|
|
|
Flace wrote:
Ok, the problem goes away if I define both UNICODE as well as _UNICODE.
Is this how it is supposed to be?
It does seem so
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Get rid of the _MBCS and define both UNICODE and _UNICODE.
#include <windows.h>
#include <tchar.h>
const TCHAR *mykeyname = "Software\MyCompany";
Then call RegOpenKeyEx...
|
|
|
|
|
Oops this should read...
static const TCHAR *mykeyname = "Software\\MyCompany";
|
|
|
|
|
Anonymous wrote:
static const TCHAR *mykeyname = "Software\\MyCompany";
Small Question, Why are you using static with const or vice versa
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Crap everything, he forgot the _T macro. Also, you don't need the static. Correctly, it should read:
const TCHAR *mykeyname = _T("Software\\MyCompany");
|
|
|
|
|
One Stone wrote:
Correctly, it should read:
Actually My Question is:- if he want to make any thing static then why he making it const or vice versa.as after making const we cannot change it value, so no use of static.
Secondly :-
One Stone wrote:
const TCHAR *mykeyname = _T("Software\\MyCompany");
const TCHAR *mykeyname = "Software\\MyCompany";
This will compile too, but that wouldnot be right approach .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
After diving a lot in MS and other web waters, I must draw the following conclusion:
many ambiguities are kept alive about GDI, GDI+, DIB, DDB, ... and the GDI/GDI+ doc doesn't help much.
One of the best article I read about GDI+ is from Borland! ( http://bcbjournal.org/free_issue/vol8_num6.4.htm )
There are some abiguities I'd like to clear, please read the questions carefully and reply only if you know the answers for sure, thank you.
1. GDI+ Bitmap class loads a file
- is the bitmap generated for sure a DIB? (ie not a DDB)
will the bitmap have the same PixelFormat as the one inside the file for sure?
(should be the case, but read so many various things on the web...)
2. GDI+ Bitmap class and palettes
When a GDI+ Bitmap is read from a file in which a palette is embedded (e.g. a GIF) the superclass Image provides a GetPalette method, while the subclass Bitmap does not. So, what happens after a Bitmap::LockBits where the requested PixelFormat is Indexed?
- Does LockBits provides a color table (palette) somewhere? How to get it?
3. GDI+ to HBITMAP etc...
After reading an image from a file, assuming the file format of Image is the one of the file, the corresponding old HBITMAP handle is necessary:
- will Bitmap::GetHBITMAP provide a "safe" handle (ie the Image object can be deleted?)
What about the Palette, if any:
- is a HPALETTE handle available somewhere, or the Image::GetPalette() call is necessary (after GetHBITMAP) and the re-construction of a HPALETTE object/handle is mandatory?
Thanks again
Regards
|
|
|
|
|
EastMohican wrote:
is the bitmap generated for sure a DIB?
Yes, it always has the same pixel format as the image on disk
EastMohican wrote:
Does LockBits provides a color table (palette) somewhere? How to get it?
Lock bits provides the bits only, and may actually throw an exception if the image is 8 bit.
EastMohican wrote:
will Bitmap::GetHBITMAP provide a "safe" handle (ie the Image object can be deleted?)
I doubt it. An Image has to be a HBITMAP, no matter which way you look at it. So the easiest thing, and the least memory intensive thing, would be to pass the handle of what I assume is internally a DIBSection.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks a lot Christian.
Maybe a last question about palettes:
after getting the HBITMAP from my GDI+ Bitmap::GetHBITMAP() method, in case the bitmaps is (for instance) Indexed 8 bits, where can I get the accompanying Palette information (if any) in order to make a HPALETTE (GDI)object?
|
|
|
|
|
I'm sorry, I skipped that one as I have no idea. I only know about the exception thrown because people who have used my image processing code have reported it. I tried to stop my code loading GIF ( there was some talk that using GDI+ to load gif means that the third party needs to pay a Unisys licence, even if the code is free ), and I never use palettised images.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
EastMohican wrote:
after getting the HBITMAP from my GDI+ Bitmap::GetHBITMAP() method, in case the bitmaps is (for instance) Indexed 8 bits, where can I get the accompanying Palette information (if any) in order to make a HPALETTE (GDI)object?
I think that, assuming the HBITMAP is a DIB, then calling GetDIBits and using DIB_PAL_COLORS will cause the BITMAPINFO's bmiColors array to be filled with the palette values.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Hi Jim,
thanks for your contribution.
Actually GetDIBits will take the bitmap handle and process the data in order to provide the requested format. E.g. DIB_PAL_COLORS for indexed colors, or DIB_RGB_COLORS for straight colors...
However, I don't need another processing! But rather retrieve the Palette information after GDI+ Bitmap::GetHBITMAP has been called... if the initial bitmap (handled HBITMAP) was actually Indexed, there should be the information somewhere in the Bitmap object!
regards
|
|
|
|
|
Christian Graus wrote:
EastMohican wrote:
is the bitmap generated for sure a DIB?
Yes, it always has the same pixel format as the image on disk
Yes, but I was a little bit confused working with grayscale JPEGs. Working with such images using libjpeg , for example, you can determine that the image is grayscale. But GDI+ is loading such images using Format8bppIndexed. So, how to check that the image is grayscale ? Only analyzing it's palette.
Christian Graus wrote:
Lock bits provides the bits only, and may actually throw an exception if the image is 8 bit.
Yes, it may. But why not to lock using the pixel format of the image ? So, you will not get exceptions. Besides, you will not get exception if you are locking for read only. It works for 8 bit images locking them as 24 bit.
Andrew
|
|
|
|
|
Thanks Andrew. Any idea about the Palette if I want to convert a GIF to HBITMAP for instance (without forcing the pix format as > 8 bits) ?
<< after getting the HBITMAP from my GDI+ Bitmap::GetHBITMAP() method, in case the bitmaps is (for instance) Indexed 8 bits, where can I get the accompanying Palette information (if any) in order to make a HPALETTE (GDI)object? >>
|
|
|
|
|
Sorry, but I have no ideas. I remember, that I had some problems with palette of HBITMAP. But it was not so important for me that time. I am working mostly with image processing, so it's not preferable for me to work with 8 bpp images (only if they are grayscale).
Andrew
|
|
|
|
|
Thanks anyway.
Amazing the tremendous confusion dominating the Web and newsgroup regarding GDI/GDI+.
Even the posts apparently signed from Microsoft staff are often vague or ambiguous and sometimes wrong. Sounds like nobody is working on it...
Regarding the help, it's like a supermarket where apples are between the shoes and the fridges! Important linked concepts are rarely connected, it's worse than hell to solve the puzzle(s).
Is there a pilot in the plane?
|
|
|
|
|
EastMohican wrote:
Is there a pilot in the plane?
He is jumped out
MS forgot about Video for Windows after DirectShow was appeared. So will be with GDI too, because there is GDI+ now. They are too busy with their new technologies.
Andrew
|
|
|
|
|
Andrew Kirillov wrote:
But why not to lock using the pixel format of the image ?
I said 'may' because all I know for sure is that it does in my image processing articles ( which I never tested against 8 bit, IMO 8 bit is crap ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
Any easy way to set breakpoints on a bunch of functions? Eg all methods in a class or functions matching a string?
Thanks.
|
|
|
|
|
Writing a macro for that might just help.
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
Hi!
I create an object of class A in my code. An object of dialogWnd, dlg, is created. See dialogWnd below. When I attempt m_Slide.SetRange(1, 300), in OnInitDialog(), my program crashes every time. Can anyone give me some idea what is going on? Also, how do you distinguish between CSlider controls if you have more than one is a dialog resource?
class A : public CMDIChildWnd
{
public:
dialogWnd dlg;
};
BOOL dialogWnd::OnInitDialog()
{
CDialog::OnInitDialog();
m_Slide.SetRange(1, 300);
return TRUE;
}
class dialogWnd : public CDialog
{
public:
dialogWnd(CWnd* pParent = NULL);
virtual ~dialogWnd();
//Dialog Data
//{{AFX_DATA(dialogWnd)
enum {IDD = IDD_DIALOGWND};
CSliderCtrl m_Slide;
//}}AFX_DATA
Thanks.
Jerry
|
|
|
|
|
jerry1211a wrote:
my program crashes every time.
Kind of vague on your description aren't you? Usually when a program crashes (especially in DEBUG mode) there will be some kind of error message. If you would enlighten those of us without mind reading abilities as to what the actual error message is we may be able to help you.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
jerry1211a wrote:
how do you distinguish between CSlider controls
Check with GetDlgCtrlID.
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|