|
How Can I Load External Bitmap File "C:\\Test.bmp"
To A CBitmap Object
Thanks
|
|
|
|
|
Call LoadImage() first, then use CBitmap::Attach() .
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thank you
I Have Tried It Before (Ask This) , But Nothing Was Happen .
Ok I Think I Am On Correct Way ,I Will Try It Again
Thank You Anyway
|
|
|
|
|
Use LoadImage() function but i think it works only for .bmp file.
-@SuDhIrKuMaR@-
|
|
|
|
|
Thank You
Yes, I Know
I Need Only Bitmap (.BMP)
Other Formats Are Not Required
|
|
|
|
|
I want to have one diferent cursor for the keyboard.
It must apear when I click the mouse left button.
danginkgo
|
|
|
|
|
So do you need to respond to the WM_SETCURSOR message?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How can I get the value of the alpha channel for every pixel in a bitmap?
danginkgo
|
|
|
|
|
Is this a bitmap in a file, from an HBITMAP?
There are loads of resources in MSDN that will help. If you start with GetDIBits, you can follow the documentation from there.
*IF* a bitmap has an alpha layer, it will be 4 bytes per pixel, one for R, G, B, and A respectively. (Ok, I'm pretty sure A comes first).
You can look at the bitmap header, and see 32 bits per pixel set.
It's quite a bit of fiddly work, but not rocket science.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
OK, thank you for help.
danginkgo
|
|
|
|
|
I use ::GetOpenFileName instead CFileDialog to show the OpenFile Dialog.
accidently I found it(the dialog) a modeless dialog, user can click the button to show as many OpenFile Dialogs as she/he wants, this is not the thing I want.
Is it possible to make ::GetOpenFileName openfile Dialog modal?
|
|
|
|
|
You could try something like this perhaps: Code removed
Sandip's answer is the best way to go about it.
modified on Thursday, July 10, 2008 2:45 AM
|
|
|
|
|
Specify valid window handle in parameter hwndOwner
if you specify NULL it would create modless dialog.
i hope it helps.
Regards,
Sandip.
|
|
|
|
|
I always specify the hwndOwner, it doesn't work.
|
|
|
|
|
i tried this and it works fine for me.
void CTrialMFCDlg::OnOK()
{
OPENFILENAME ofn;
char szFile[260];
HWND hwnd;
HANDLE hf;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = this->GetSafeHwnd();
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileName(&ofn)==TRUE)
MessageBox("Open");
else
MessageBox("Cancel");
}
Regards,
Sandip.
|
|
|
|
|
And I found a misunderstanding problem, when I first show the openfile Dialog,
it just shows on the topmost corner in the screen(it means the openfile dialog shows in the (0,0) according the screen coordination).
But when show the openfile dialog after, it shows in the center relative to the main dialog.
Who can tell me why?
|
|
|
|
|
fantasy1215 wrote: the openfile dialog shows in the (0,0) according the screen coordination).
But when show the openfile dialog after, it shows in the center relative to the main dialog.
I see this behavior, only when the owner of the dialog opened is not specified. Specify the handle of your application's window as the owner of the dialog that you open.
|
|
|
|
|
Thanks all of you. I specify the wrong hwndOwner handle, I reCreate a simple project, it works fine.
BTW, is it possible to SetIcon for the ::GetOpenFileDialog dialog?
It always use the IDR_MAINFRAME icon.
|
|
|
|
|
Hi,
I have 2 threads in my app.
one is main application thread which has UI.
second is the worker thread.
second thread will get some status from a database and send the information to the main thread using SendMessageAPI. One of the parameters in the SendMessage API is a global variable across the threads.
After the recieving the message from second thread, first thread will display the error to the user and return the control so that the second thread can monitor the status continuously.
But at some point, my app hangs.
I suspect that the hang happens in this loop.
As the return depends on the response from the main thread (thru user input via messagebox), i could not use SendMessageTimeout API in this case.
1. Is it because of the global variable usage in SendMessage function?
Can you please let me know how can i come out of this problem.
Any help is appreciated.
Selva
|
|
|
|
|
Please post some code: from your worker thread when you send the message and from the main thread where you handle this message.
By 'hangs' you mean that your UI freeze completely and you can't do anything anymore with your app ?
|
|
|
|
|
Hi,
Thanks for the reply.
Code will look like below.
int g_nInt;
Main thread
LRESULT CMyDlg::OnProcessMsg(WPARAM wparam, LPARAM lparam)
{
Display Message box ....... Get result from user.
return 0;
}
Worker thread
{
get status from DB.
GetMainWnd()->SendMessage(PROC_MSG, wp, g_nInt);
.....
GetMainWnd()->SendMessage(PROC_MSG2, wp, lp);
.........
}
Yes. My main app window looks like freezed (continuous even after an hour).
Thanks in advance.
Selva
|
|
|
|
|
SendMessage is a blocking function: it will only return once the message has been processed by the other window. In your case, it will return only after the user has closed the MessageBox. You didn't provide enough code for me to verify this but you probably have a deadlock: your worker thread is waiting for the UI thread (because of the SendMessage function) which is in turn waiting for the worker thread.
If your design allows it, try with PostMessage instead of SendMessage: PostMessage puts the message in the message queue of the window and returns immediately.
|
|
|
|
|
Hi,
Thanks for the reply.
Main thread won't be waiting for the worker thread..
only if the second request from the worker thread comes, it will be processing.
But i too suspect that its because of the deadlock.
But my doubt is,
whether passing the global variable (which will be accessed by both the threads) causes this hang. any way storing the value in global variable will happen with proper locks from both the threads.
But whether passing this as the parameter to the SendMessage causes any problem?
Thanks in advance.
Selva
|
|
|
|
|
Sorry but your question is not really clear. Please post some more relevant code instead of explaining what your code does. Anyway, why do you pass the value in the message ? It is globally available so, there's no need to pass it in the message. But accessing this variable from two threads won't make your UI hang (unless you are using critical section to access it, then the problem might come from that).
SelvaKr wrote: any way storing the value in global variable will happen with proper locks from both the threads.
I'm not sure what that means but if you are using critical section, then this is probably the problem.
Did you try with PostMessage as I told you ? What happened ?
|
|
|
|
|
Hi,
Thanks for the reply.
I will try postmessage instead of SendMessage and
reply in case of any problems.
Thanks a lot.
Selva
|
|
|
|