|
Use the following code
On the cpp file add the following.
CRect tmprect(100,100,300,300);
m_statTest.Create(_T(""), WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_CENTERIMAGE, tmprect,this);
bm.LoadBitmap(IDB_BITMAP);
HBITMAP hBitmap = (HBITMAP)bm.GetSafeHandle();
m_statTest.SetBitmap(hBitmap);
on the header file create the instance of bm as
CBitmap bm;
This will work
|
|
|
|
|
To make your code working change the first parameter in function ::LoadBitmap from NULL to AfxGetApp()->m_hInstance .
|
|
|
|
|
Thanks Sujan and Andrzej. Both solutions seem to work..
Seems to me that the MSDN library which explains the SetBitmap function of the CStatic control should be updated...
I got that specific codepart for the control created on the stack from the MSDN lib.
Ah another thing, when using the code part:
m_statCtrl.SetBitmap(::LoadBitmap(....)); //m_statCtrl is CStatic control
don^t you loose memory? I mean the documentation on LoadBitmap says that one should call DeleteObject on handles created by LoadBitmap... On the other hand, MSDN suggests this code-snippet to set the bitmap on a CStatic... I don^t think the CStatic deletes the handle when it gets destroyed or changed, or does it?????
(another thing that should be updated in MSDN perhaps?)
Greetz,
Davy
|
|
|
|
|
You will not have memory leaks because the system automatically deletes handles when the process that created them terminates.
|
|
|
|
|
How to get out the progress status in DirectShow when I encode a media file for example ?
|
|
|
|
|
I need to be able to mointor accessed files accessed on windows like sysintenal file mointor how I can do this.
|
|
|
|
|
you can try using The FindFirstChangeNotification(easier) or SHChangeNotify function.
|
|
|
|
|
Hi All,
Can some one tell me the differences between semaphores,critical section and mutexes.When should they be used(i know these are used for synchronization between threads) and the advantages/disadvantages of them over the other.
Thanks in advance
Regards
Raghu
|
|
|
|
|
in one sentence.
Semaphore can be used to manage resources, criticalsection to synchronize access to shared data within same(single) process and mutex to synchronize access to shared data among different process also.
There is no spoon.
mail
|
|
|
|
|
Hello Friends,
I got a problem.
I had splitted the actual view into 4 parts. every view is been derived from different view's class.
The main problem is the one splitter window which has been derived from the FormView has got 2 edit boxes which will resizing itself based upon the size of the window. and when I click in someother view some message has to be displayed in these edit boxes. for example when I click in View1 then some message which I pass from View1 has to be displayed in the edit boxes present in the View2.
I am trying but its always giving me assertion failed and when I debug it its giving the asserting failed in the SetWindowText message. I had created 2 different variables of type CEdit.
Neelesh K J Jain.
I am getting the assertion failed in the winocc.cpp at line 229, When I am using the SetWindowText
Neelesh K J Jain.
|
|
|
|
|
Get the view address using GetActivePane() function and use it for setting the window text using setwindow text function
eg.
CMyView *pView = (CMyView *) mysplitter.GetActivePane();
pView->SetWindowText("Hi");
|
|
|
|
|
Its giving me a problem at the SetWindowText message in the Winocc.cpp file.
|
|
|
|
|
Check the view's pointer's value @ debug mode. Also you can use the GetPane to get the view's pointer. Have a look @ msdn.
|
|
|
|
|
Hi Sujan,
Can you please explain with code please.
|
|
|
|
|
Hi Sujan,
Can you please explain with code please.
Neelesh K J Jain.
|
|
|
|
|
Hi Jain
I am @ the office, i'll surely do it when i reach home.
Sujan
|
|
|
|
|
Hi Jain
Here i do consider that i am having two panes ie two views, first the CCallManagerView(0,0) and the other CUserView(1,0). So when i do need to set some value to the CCallManagerView's control from CUserView, i'll be using the following code
void CUserView::SetValue2Manager(void)
{
CMainFrame *pMainFrame = (CMainFrame *) GetParentFrame();
CCallManagerView *pView = (CCallManagerView *)pMainFrame->m_wndSplitter.GetPane(0,0);
if (pView)
{
pView->myEdit.SetWindowText("Hai From Call Manager");
}
}
Hope this may help you. If you want the CUserView then use GetPane(1,0)
Sujan
|
|
|
|
|
It looks like microsoft stopped providing the DDK for download. Does anyone know where else this can be obtained?
Thanks,
Jill
|
|
|
|
|
|
Good Day
I have a device that upon plug into USB, loads the driver USBAudio.sys. I wish to develop a GUI for my device.
How can i go about doing it? Is there any info about the USBAudio.sys which i can reference?
Is there anyway which my GUI can directly interface with the USBAudio driver to pass data from GUI to USB to my device?
Thanks!
|
|
|
|
|
I want to open a pipe to the usb port and write some data. Can someone point me in the right direction?
Thanks,
Jill
|
|
|
|
|
I don't have a big experience with USB but I'm using a USB device and for this one, they provided a device driver that is used to communicate with the device. I can send control codes to this driver using the DeviceIoControl function. These control codes where also provided by the manufacturer of the USB device.
So every action (open a pipe, write data on this pipe, read data, ...) is performed via this function. I open the device with the CreateFile function.
Hope this helps...
|
|
|
|
|
I have source code for a program that I want to run on several PC's. I only have one PC with Visual studio so cant just re-compile the code on all the PC's.
I have tried just copying the .exe file generated by visual studio to all the PC's but the program does not seem to work properly. I am told this is because the .exe is dependant on a few .dll files.
I need to know how to package the .exe and the .dll files together to be installed on several PC's.
I think in Visaul Basic I could use the Package and Deployment Wizard, is there an equivalent to this in Visual C++?
I have not been able to find anything helpfull on the internet, so if anyone has any suggestions, please let me know.
Cheers
|
|
|
|
|
Gee, it's kind of hard to know what your program needs, if you're not going to tell us what it uses.
There is a program called 'Depends' ( from memory ) in the stuff that comes with VS, it might tell you waht you need. If you use MFC, you need the MFC dll, if you use C in your program, you'll need MSVCRT, etc.
I assume it's a release build ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Sorry Christian, I didnt write the code so I dont know what it uses. like I said, I am vey much a beginner and the code is way over my head.
Thanks for the help though. Where can I find those dll's that you mentioned?
|
|
|
|