|
Hi!
I am loading a file into a CBitmap object, draw it and so on. Then I save it to my own file format and like to read it afterwards again. The saved values and loaded values are the same but I cannot create a bitmap from the loaded values.
Here is my code:
//read from my file bitmap header
fread(&bit,sizeof(BITMAP),1,f);
int bsize=bit.bmWidthBytes*bit.bmHeight;
//read bitmap bits
buf=(BYTE*)malloc(bsize);
fread(buf,bsize,1,f);
//delete previous bitmap
DeleteObject();
//and create new one
CreateBitmap(bit.bmWidth,bit.bmHeight,bit.bmPlanes,bit.bmBitsPixel,buf);
The result of CreateBitmap() is 1 so it seems to work. But my screen stays blank. When I remove DeleteObject and CreateBitmap and use SetBitmapBits with my loaded bitmap data then I can see my saved picture. This is because I overwrite the previous loaded picture.
The problem seems to be CreateBitmap...anybody an idea?
Please help!!
Thx
Flo
|
|
|
|
|
Floschi wrote:
I am loading a file into a CBitmap object, draw it and so on. Then I save it to my own file format
Can you show, how u are saving the bitmap?
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
Sure, but I checked the written and read data and its the same so I think this works. But here it comes:
BITMAP bit;
BYTE *buf;
//get loaded bitmap header
GetObject(sizeof(BITMAP),&bit);
int bsize=bit.bmWidthBytes*bit.bmHeight;
//get bitmap bits
buf=(BYTE*)malloc(bsize);
this->GetBitmapBits(bsize,buf);
//write
fwrite(&bit,sizeof(BITMAP),1,f);
fwrite(buf,bsize,1,f);
Hope it gives you an idea!
Thx!
Flo
|
|
|
|
|
Hi Expertise
Please help me how to create Popup Menu in Tree Control using MFC.
Thanks
Muru
|
|
|
|
|
I think CreatePopupMenu[^] should help you solve the problem.
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
In Continuation with Mr. Nilesh, Handle the Left Click or Right Click in Tree Control to Display your Popmenu.
i.e. the Write Code Stated by Mr Nitesh In handller of Mouse Message
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Million thanks to both of you. It is working
|
|
|
|
|
Hi
I am using the MprConfigGetFriendlyName function in a program of mine.
It works well if I'm an administrtor on my machine, but when I switch
to a restricted user, I get "Access denied" from the funciton.
I can't find any info about rights anywhere on MSDN.
Can anyone give me a hint of how to proceed.
|
|
|
|
|
Per Nilsson wrote:
I can't find any info about rights anywhere on MSDN.
Check here[^]
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
i have created a window using CreateWindow() having buttons as child windows. now i want to have focus on one of the buttons and also have tabbed control on the window, i.e, when i press tab the control shifts from one button to another. Also when i press ENTER on one of the buttons it should get executed. how do i achive it? it basically means that my window is not responding to the keyboard control. so how do i achieve it?
|
|
|
|
|
Create your controls with WS_TABSTOP, and set the tab order for movement.
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
i had created the controls with WS_TABSTOP. how do i set the tab order movement?
|
|
|
|
|
Trap the 'TAB' key in the parent window and move over the controls using GetNextDlgTabItem function. Hope this helps.
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
In a dll program, I use createmutex and releasemutex .
However, the dll still could not release from memory.
Is there a method to see which function are using the memory?
Thanks!
Zhou yuanxin
|
|
|
|
|
U mean see the DLL ?
If so DLL Spy will see the DLL actions.
Try see attach and detach to load and unlad DLL or drivers
|
|
|
|
|
Hi,
I want to know what are the terms used in conjunction with Message...
that is...
1) Message Map
2) Message pump
3) Message loop
4) Message handle
5) Message Queues.....
and anything else followed with messages....
Best Regards,
Janakiraman
|
|
|
|
|
Message man !!! The person who sits inside the computer and makes sure all the messages go where they should.
Is this some sort of pop quiz, or do you just want information about message routing ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi
I created a window, and the windows's client aera(CRichEditCtrl) was transparented by "SetLayeredWindowAttributes(hwnd,[clent back color],255, LWA_COLORKEY);",
but the mouse event is not be done.
How do it then it will catch the mouse event?
Help me!
|
|
|
|
|
This has probably nothing to do with the transparent thing. Which mouse events do you want to catch ? What kind of application are you working with ?
~RaGE();
|
|
|
|
|
I want catch the all of mouse event. It is a text edit application, and the background is transparent. But when it transparent the text cannot be selected when mouse double click or drag. I want to do it.
Thanks
|
|
|
|
|
I dont get C++
How do if and else statements work inside the the switch Entry handler. Can anyone clearify how to use if and else inside the Switch part? its marked from arrow to arrow thank you..... Hugs =P
void exitfkt(void)
{
MessageBox(NULL,"Unload Dll", "Test", MB_ICONINFORMATION | MB_OK);
}
// Loading of the driver at start of the driver
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
>>>>>> int SCO_AS6(void)
{
unsigned short error;
double measure_range;
unsigned short state;
double value;
error = SCO_AS6();
if (error != SCO_ERR_OPEN_DRIVER)
{
>>>> return TRUE;
}
else FALSE;
}
break;
// Can be left out
///////////////////////////////////////////////
case DLL_THREAD_ATTACH:
MessageBox(NULL,"Dll in Use", "Test", MB_ICONINFORMATION | MB_OK);
break;
case DLL_THREAD_DETACH:
MessageBox(NULL,"Dll unused by a Program", "Test", MB_ICONINFORMATION | MB_OK);
break;
///////////////////////////////////////////////
// If not needed can be left out
case DLL_PROCESS_DETACH:
atexit(exitfkt);
break;
}
return TRUE;
}
|
|
|
|
|
Anonymous wrote:
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
>>>>>> int SCO_AS6(void)
{
unsigned short error;
double measure_range;
unsigned short state;
double value;
error = SCO_AS6();
if (error != SCO_ERR_OPEN_DRIVER)
{
>>>> return TRUE;
}
else FALSE;
}
break;
I don't see the problem here. If ul_reason_for_call == DLL_PROCESS_ATTACH, then SCO_AS6() is called. It obviously returns an error code. If the error code is SCO_ERR_OPEN_DRIVER, it returns FALSE, otherwise it returns TRUE.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
For no reason i cant get it to work though it says } missing then ; missing. So i thought my code might be wrong .
void exitfkt(void)
{
MessageBox(NULL,"Unload Dll", "Test", MB_ICONINFORMATION | MB_OK);
}
// Loading of the driver at start of the driver
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
int SCO_AS6(void)
{
unsigned short error;
double measure_range;
unsigned short state;
double value;
error = SCO_AS6();
if (error != SCO_ERR_OPEN_DRIVER)
{
return TRUE;
}
else FALSE;
}
break;
case DLL_PROCESS_DETACH:
atexit(exitfkt);
break;
}
return TRUE;
}
|
|
|
|
|
it looks right somethign is still wrong nothign works,.... The idea should be working.
|
|
|
|
|
Have you tried stepping through the code to see what happens ? I've found an error below, this could couldn't possibly compile.
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
// This really sucks. Are you using C ? If not, why are these at the top ?
unsigned short error;
double measure_range;
unsigned short state;
double value;
error = SCO_AS6();
if (error != SCO_ERR_OPEN_DRIVER)
{
return TRUE;
}
else FALSE; // This should say else return FALSE;
}
break;
Christian Graus - Microsoft MVP - C++
|
|
|
|