|
First, you need to be more clear about the error. Is it a runtime error, or compile time?
What is the error?
|
|
|
|
|
Hey, what is this? You reading over my shoulder?
L u n a t i c F r i n g e
|
|
|
|
|
|
mostafa_pasha wrote: But when i try to compile the code or run the code under windows XP, the program crashes/ the compiler throw an exception.
Which is it? Does it fail to compile, or does it crash when you run it? If it fails to compile, what is the specific error message?L u n a t i c F r i n g e
|
|
|
|
|
first, it is runtime error!
I said that when i debug the code under windows XP! (it means i can compile and run the program), pBmp1 which is the GDI+ object is NULL!!! but under windows vista/7, All is OK.
My program is MDI. My project setting is USED MFC LIBRARY AS SHARED DLL!
Does it depend on the updates for windows XP or Not?
Best,
MJM
|
|
|
|
|
mostafa_pasha wrote: I said that when i debug the code under windows XP! (it means i can compile and run the program), pBmp1 which is the GDI+ object is NULL!!!
Noooo, you said this:
mostafa_pasha wrote: But when i try to compile the code or run the code under windows XP, the program crashes/ the compiler throw an exception.
There is a difference, although I take it from the second post that the first was incorrect; that is, you say now that you CAN compile under XP.
mostafa_pasha wrote: My program is MDI.
Probably irrelevant.
mostafa_pasha wrote: My project setting is USED MFC LIBRARY AS SHARED DLL!
Again, probably irrelevant, although you could build the project with MFC linked as a static library to eliminate the possibility.
mostafa_pasha wrote: Does it depend on the updates for windows XP or Not?
Perhaps; I don't know if the GDI+ runtime was affected by any updates, but it's always advisable to make sure your system is fully up to date. If it isn't, that's a good place to start, although I wouldn't hold out TOO much hope.
Have you tried using LoadImage instead of LoadBitmap? LoadImage will allow you to specify that you want the image loaded as a DIBSection, which is device independent. (Are your display settings different in XP? LoadBitmap tries to load the image in a display-compatible format; LoadImage might get you around any problem associated with this.)L u n a t i c F r i n g e
|
|
|
|
|
I think you can debug into Bitmap::FromHBITMAP() function and see what is going wrong.
|
|
|
|
|
return NULL
It means can not initilaize Bitmap!!!
Does it mean it can not initialize the GDI+?
inline Bitmap*
Bitmap::FromHBITMAP(
IN HBITMAP hbm,
IN HPALETTE hpal
)
{
return new Bitmap(hbm, hpal);
}
|
|
|
|
|
mostafa_pasha wrote: return NULL
If it returns NULL then it means the function failed and you should use GetLastError() to find out why. Incidentally the code above is somewhat different from the code in your original message. Try to use exactly the same code and trace through it with the debugger noting all the values of your variables.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
the code is here:
HBITMAP hbmp1 = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1));
ASSERT(hbmp1!=NULL);
Bitmap* pBmp1 = Bitmap::FromHBITMAP(hbmp1,NULL);
hbmp1 0xb8051055
pBmp1 0x00000000
in LoadBitmap function:
inline Bitmap*
Bitmap::FromHBITMAP(
IN HBITMAP hbm,
IN HPALETTE hpal
)
{
return new Bitmap(hbm, hpal);
}
void* (operator new)(size_t in_size)
{
return DllExports::GdipAlloc(in_size);
}
in_size = 16
return 0x000000000
Best,
MJM
|
|
|
|
|
In your call to Bitmap::FromHBITMAP(hbmp1,NULL); you have given NULL as the second parameter; are you sure this is correct? The documentation here[^] says this must be the handle to a GDI palette. You should also use GetLastError() as I suggested previously to check why the call failed.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
You can actually debug further into Bitmap() constructor to see what is happening there.
I hope you have already initialized GDI+ by calling GdiplusStartup() function and checking it's return value.
|
|
|
|
|
Hi All,
Using Visual Studio 2005 C++ to create an WMP visualization.
I have an array of values id like to create checkboxes for dynamically.
i.e. the array contains the enumerated com ports on computer. i want to be able to select an checkbox and store the value.
Example
comports[5] = {"COM1","COM2","COM3","COM4","COM5"};
need to create an checkbox for each value in the array with the value as the dialog text
Any ideas?
p.s. using atl in the project
|
|
|
|
|
Something along these lines -
CButton buttons[5];
comports[5] = {"COM1","COM2","COM3","COM4","COM5"};
CRect rect;
for (int i = 0; i < 5; i++)
buttons[i].Create(comports[i], BS_AUTOCHECKBOX,&rect, this, FIRST_BUTTON_ID + i);
Alternatively, you can just use SetWindowText to ... errr ... set the window text. If you don't know ahead of time how many buttons there will be, use a dynamic array of CButtons and instantiate each individually before calling it's 'Create' member function.
And of course you'll have to initialize the CRect with appropriate values.L u n a t i c F r i n g e
|
|
|
|
|
So what exactly do you need help with? Creating the checkboxes, selecting one, or storing a value?
|
|
|
|
|
Bit of the first and last bits.
Need help creating the checkboxes from the array.
Then i need to store the dialog values in an array to be used later. I've got the basics of the array etc, My main problem is creating the checkboxes from the array
|
|
|
|
|
Steven Foxton wrote: Need help creating the checkboxes from the array.
Did you see here?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Perhaps I should have used a larger font or something.
L u n a t i c F r i n g e
|
|
|
|
|
Trying your answer out now LunaticFringe.
Having an bit of difficulty in declaring the array in the header file though.
getting the below error
CPropertyDialog.obj : error LNK2005: "class ATL::CSimpleArray<class ATL::CStringT<char,class ATL::StrTraitATL<char,class ATL::ChTraitsCRT<char> > >,class ATL::CSimpleArrayEqualHelper<class ATL::CStringT<char,class ATL::StrTraitATL<char,class ATL::ChTraitsCRT<char> > > > > sPorts2" (?sPorts2@@3V?$CSimpleArray@V?$CStringT@DV?$StrTraitATL@DV?$ChTraitsCRT@D@ATL@@@ATL@@@ATL@@V?$CSimpleArrayEqualHelper@V?$CStringT@DV?$StrTraitATL@DV?$ChTraitsCRT@D@ATL@@@ATL@@@ATL@@@2@@ATL@@A) already defined in USBGlowLight.obj
1> Creating library C:\Users\sfoxton\Documents\Visual Studio 2005\Projects\USBGlowLight\Debug\USBGlowLight.lib and object C:\Users\sfoxton\Documents\Visual Studio 2005\Projects\USBGlowLight\Debug\USBGlowLight.exp
1>C:\Users\sfoxton\Documents\Visual Studio 2005\Projects\USBGlowLight\Debug\USBGlowLight.dll : fatal error LNK1169: one or more multiply defined symbols found
you can have an look at the header if you like
http://www.4shared.com/file/228257607/9cf3e5f/USBGlowLight.html
Problem seems to be the declaration on Line 14
CSimpleArray<CString> sPorts2;
Idea is to declare the array in the header file, have the .cpp file create the checkboxes. Then in my main Viz .cpp it can read the array values
|
|
|
|
|
Nvm got it working. was an stupid error where id used extern to carry an array over, and then looped it back on itself.... so was passing the array back and forth continuesly
|
|
|
|
|
Cool - sorry I didn't get back quicker. L u n a t i c F r i n g e
|
|
|
|
|
Question: How to I Debug a class that lockup during runtime usng the debug function in MS VS 6.0? At the "Start Debug" option there are "GO", "Step Into" and "Run Cursor".
I tied to click on the Go option and get a message saying the the FileName.exe not found. Although the project was complied without any errors.
Thanks!
|
|
|
|
|
you could start your DEBUG application directly from explorer and use the "attach to process" (if that existed in VC6) to start debugging it. Watched code never compiles.
|
|
|
|
|
Thanks, I can now run the debuger and see the error log bellow. How will I know which part of the code the application locks up? The step into is grayed out once the debuger startes. The logs dont really tell you where it locks up in the code It show the dll that are beening loaded at runtime.
Thanks again.
|
|
|
|
|
If I don't remember bad, when you are debugging you can press F11 and it will go deeper into the calls and code that it is being called although it may be not your own code (for instance the MFC code). In other words, if you run debugger with F10 you stay in the same class getting the return of a function but if you use F11 you get into the called function.Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|