|
first, go to classwizard from by right clicking on your dialog class
click the member variables tab and add a variable for your picture CStatic as a CStatic CONTROL, and call it m_picture. Now left click on your CStatic in the resource editor and make sure it's set to type: bitmap
Now double click on the button you want to control the picture change in the resource editor and let it add the mapped function for you by hitting "ok".
Now you should be in your dialog with the new button pressed mapped function
now add this code like so
void Cdlg::OnButtonClick()
{HBITMAP hBitmap = (HBITMAP) ::LoadImage(NULL, _T("C:\\some\\image\\location.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
m_picture.SetBitmap(hBitmap);
}
now compile and watch as the code works.
PS- that obviously works just as well using a resource bitmap, and if it's not a dialog you would obviously create the CStatic naming it m_picture(class member) and initialize it and show it before using it.
|
|
|
|
|
THANK U!!!!!!!! IT WORKS!
|
|
|
|
|
Hi everybody
I am trying to use the CheckSpelling method of MSWord in order to check how a word is spelled. It works perfectly with English but I want to test also against Spanish words. Now I have installed Spanish in Word. I have checked that word must detect language change automatically and also when testing against Word spell check works fine with Spanish words.
The method call that I use is:
oWordApp.CheckSpelling(szWord, vOpt, vTrue, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt);
It seems to me that I cannot find a way to change the spellchecking language in runtime. I would appreciate any suggestion.
Thank you very much.
Spiros Prantalos
Miami the place to be!!
|
|
|
|
|
Hi,
I have a listview as one of my splitter panes. A function in this view is as follows:
void MyFunction(CString* str)<br />
{<br />
}
But whenever I try to do so, it asserts saying that it isn't a window. A listview works just fine in another 2 applications I have a listview in.
Everything is standard...I haven't overridden any functions. The documentation says I don't need to create a ListCtrl because the view did.
Any suggestions?
Shutter
|
|
|
|
|
this may sound awkward, but did you try passing the CString by value instead?
I've had some nasty stuff happen when I tried passing CStrings by a pointer then using them in controls.
hey
|
|
|
|
|
That was a typo there...actually, I'm just using a CString instead of a CString*... I did try your code, but unfortunately it didn't work either.
I've tried many functions... they all assert. It seems to think that there isn't a window there.
Perhaps it's a cast of some sort that I'm missing...I really have no idea.
Shutter
|
|
|
|
|
Add a member variable to the main frame that corresponds to the listview.
Kuphryn
|
|
|
|
|
Could you expand on that?
Shutter
|
|
|
|
|
In your code you get a pointer to the listview via GetListBox(). I meant you could assign a member variable to the listview instead of GetListBox().
Kuphryn
|
|
|
|
|
There's also the possibility that if you call this function from a thread that is not the creator of the listview control, this assert will fire (something like ASSERT(IsWindow(..))). Is this the case?
|
|
|
|
|
I haven't involved separate threads in the application. I've tried creating a ListCtrl in a formview, tried adding a ListCtrl into a CView, tried using a CListView... but still no luck.
The thing is, I can see the header when I have it in Report mode, and Spy++ picks up on the windows messages for it. But even calling IsWindow on it returns false.
What gets me is it's a CListView with no modification whatsoever. Oh well, I'll try more in the morning.
Shutter
|
|
|
|
|
What is the value of m_hWnd at the time you get the ASSERT failure?
Is it NULL? You haven't created the window.
Is it 0xDDDDDDDD? You have deleted the CListView object.
Is it 0xCDCDCDCD? I don't know how this could be. But it is interesting. (It would mean m_hWnd had not be initialized.)
If it is something else, what is it?
--------
There are 10 types of people in this world. Those who know binary and those who don't.
|
|
|
|
|
It comes back null. But isn't the ListView supposed to create it?
|
|
|
|
|
Nothing happens by magic. Sometimes the framework creates windows for you. Sometimes you need to create them yourself. In this case it appears you need to create the window yourself.
You have the MFC source. Read it. Debug it. Learn it.
--------
There are 10 types of people in this world. Those who know binary and those who don't.
|
|
|
|
|
I want to select a row in a List Control and then delete it by pressing a deletebutton in my dialog based program. How do I do that? Please help me, I tried so many things but it doesn't work!
|
|
|
|
|
One solution is to first determine what rows are selected. When the user presses a button, look through the selected item database and call DeleteItem(). Keep a count as you delete each item and subtract the item index in the database from the count. One reason is because as you delete an item, the the indices of items after the deleted item decreases by one.
Kuphryn
|
|
|
|
|
I started programming a "simple" DLL with dynamic linking from the main application via LoadLibrary , GetProcAddress (and the rest).
Somewhere I make a trivial fault, which so far is difficult to correct.
Everything goes well, but when the function is exected, i get the next message.
Debug Error, File chkesp.c, line 41
The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
This should give a clue, but it did not help me so far.
To my understaning both my application and dll are compiled/linked with __cdecl as standard, so I'm lost now (but hope not for that long)
Bert....
|
|
|
|
|
Have you tried following the function call through in the Debugger. A reasonable knowlodge of assembler would help here.
Do you really need to dynamically load the DLL with LoadLibrary() and if so why? If it is a) because you don't want to waiste time loading until it is required, or b) you don't know if it exists, then using /DELAYLOAD with an SEH exception handler is a much better way to go.
See: MSJ, December 1998 Win32 Q&A. http://www.microsoft.com/msj/1298/win32/win321298.aspx[^]for a good article on /DELAYLOAD.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
assuming you're exporting C functions (not C++ stuff) it might help to add ' extern "C" ' to the function declarations :
DLL's header:
extern "C" WINAPI void MyFunc(...);
DLL's implementation:
#include "DLLs header.h"
...
void WINAPI MyFunc(...)
{
}
-c
|
|
|
|
|
|
Specialisation. Write a general one which asserts false and then a specialisation that takes the base class.
I believe the member functions will then be fine, because it will know that it's of that base type.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
|
I got confused.
I have a template class
template <class T> class x
{
..
}
now I create a specialization
template <> class x<BaseClass>
{
..
}
The specialized class will know abot the base class; but if I use the main class on another type, will the overridden members of the specialized class work?
I am going to try it anyway, but would be nice to know, if I am wrong about it before I go through the whole thing.
Thank you once again.
My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers
modified 29-Aug-18 21:01pm.
|
|
|
|
|
is there any addin or standalone tool for Visual C++ 6 Standard to integrate Code-Optimization?
|
|
|
|
|
VC6 already does code optimization. Is there some problem with that?
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|