|
What on earth is causing this to copy nothing to the CPaintDC??
-----------
void CCustomStaticControl::OnPaint()
{
// Do we have an update rect?
if (this->GetUpdateRect(NULL))
{
CPaintDC dcPaint(this);
CDC dcMem;
CRect rcRect;
this->GetClientRect(rcRect);
dcMem.CreateCompatibleDC(&dcPaint);
CBrush brushBack(this->m_rgbBack);
dcMem.FillRect(rcRect, &brushBack);
// Blit to the painting device context.
dcPaint.BitBlt(rcRect.left, rcRect.top, rcRect.Width(), rcRect.Height(), &dcMem, rcRect.left, rcRect.top, SRCCOPY);
}
}
It just refuses to draw anything. Works fine if I do it straight to the CPaintDC directly tho.
|
|
|
|
|
You have to have a bitmap selected into your memory DC.
have a look in MSDN for the CreateCompatibleBitmap() function.
void CCustomStaticControl::OnPaint()
{
if (this->GetUpdateRect(NULL))
{
CPaintDC dcPaint(this);
CDC dcMem;
CRect rcRect;
CBitmap bmp;
this->GetClientRect(rcRect);
dcMem.CreateCompatibleDC(&dcPaint);
bmp.CreateCompatibleBitmap(&dcPaint, rcRect.Width(), rcRect.Height());
CBitmap *oldbmp = (CBitmap *)dcMem.SelectObject(&bmp);
CBrush brushBack(this->m_rgbBack);
dcMem.FillRect(rcRect, &brushBack);
dcPaint.BitBlt(rcRect.left, rcRect.top, rcRect.Width(), rcRect.Height(), &dcMem, rcRect.left, rcRect.top, SRCCOPY);
dcMem.SelectObject(oldbmp);
}
}
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
Hi.
I have been wondering about the possibility of *disabling* resize feature in a window. For example, when a window is in restore setting, the user can change the size of the window via dragging one of its four size or four corners. I there a way to disable that feature completely? I am basically describing a dialog window without having to derive the class from CDialog.
In the program I am working on, I have disabled the maximize feature. The window stays restored throughout. However, the user can resize it. I would like to disable that feature too. The bottom line is the window looks better if it remains in its original settings (size).
Thanks,
Kuphryn
|
|
|
|
|
|
That small change works perfect! Thanks.
Kuphryn
|
|
|
|
|
Can some one please tell me how i can add a simple tooltip text mouse over, on a button?
Thanks!
|
|
|
|
|
|
I was wondering if there is anyway for the modeless dialog to know when the mouse moves focus away from it and to something else.
Right now I created a modeless dialog in one of my views. I do not want it destroyed when finished but just want it to hide. That is easy since it won't be destroyed until the View is gone in this case. However, I also want it to hide when I click something other than it after showing it to tell it I don't need it. I have tried onkillfocus etc but it doesn't work because that is never called.
Any suggestions?
Thanks in advance.
|
|
|
|
|
|
I was wondering if it is possible to remove the button of the app running from the task bar. I do not mean for a dialog based project as Nish has pointed out a great solution. I mean for a SDI or MDI?
Thanks.
|
|
|
|
|
|
I used CListView in an SDI program, I want the view to handle WM_CHAR event but it did not seem to respond to any key stroke at all.
I guess that's because the CListCtrl occupied full area and thus took control over the view, so maybe I should look into LVN_KEYDOWN instead of WM_CHAR? I dunno but neither way worked.
Any help are appreciated.
|
|
|
|
|
Has anybody faced the need to create up to k n-dimensional arrays at runtime? Here is an example:
Suppose that at the moment of running the program, it needs 3 2-dimensional arrays, each of them has different dimensions. The dimensions of each table are stored in another 2-dimensional array. Then, you start creating the names of each array obtaining array1, array2 and array3. Then, how do you:
a) Declare array1, array2 and array3 as dynamic arrays (i.e. double *array1, *array2, array2;)
b) How do you re-declare them, i.e.
array1 = new double[newdimension];
The problem is not how to create the name of the variables, because you can do it by handling strings and concatenating a number so they can be identified.
The main problems are (a) and (b).
If someone has a potential response, please emailme...
Eric Manuel Rosales Pena Alfaro
PhD student
Unversity of Essex
Wivenhoe Park
Colchester, CO4 3SQ
Essex, Uk
email: emrosa@essex.ac.uk
tel: +44-01206-87311
|
|
|
|
|
First, you will need to create an array to hold your dynamic number of variables. Lets say that you are working with doubles, just for the example. You can either mess with dynamic array allocation like this:
double vars[];
vars = new double[3];
...
double newVars[];
newVars = double[5];
memcpy(newVars, vars, sizeof(double) * 3);
delete[] vars;
vars = newVars;
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
Depending on what you are doing, I would recommend that you check out the Standard Template Library (STL). It makes dynamic memory allocation and management a snap, and there are a few tricks that you can do to make accessing the varaibles much easier.
At first glance the vector seems to be what you are looking for, because it is an array that will dynamically grow and manage its own memory. However there are problems with using an array, even if you are doing it the straight C++ way. As long as you will be using STL, I would recommend the map . A map you have a key, and a value that the key represents. You could make the key a string, and the value a double. Here is an example.
#include <map>
using std::map;
struct ltstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
}
};
typedef map<char*, double, ltstr> mapVars;
Here is how you will use what we just setup:
mapVars vars;
vars.insert("variable1", double*);
double value = vars["variable1"];
vars.erase("variable1");
Now you have a set of dynamically defined variables with names. Now you need a way to dynamically allocate the array of variables. This case would either be good for a vector or a map . Both of these objects will manage their own memory, and grow automatically for your. Here is how you would use the vector:
#include <vector>
using std::vector;
typedef vector<double> vecDouble;
typedef map<char*, vector<double>, ltstr> mapVecVars;
mapVecVars vars;
vecDouble newVar;
newVar.push_back(1.0);
newVar.push_back(3.14);
newVar.push_back(98.6);
vars.insert("variable1", newVar);
cout << vars["variable1"][0] << endl;
cout << vars["variable1"][2] << endl;
For efficiency, you may want to hold pointers to doubles, and vector<doubles> to prevent all of the data from being copied each time it is accessed, however, the concepts are pretty much the same.
There is a lot of information here, on something that has a million ways to implement. This way I believe will get you up and running the quickest.
The arrays will work, but they will get messy when you have more than a few dynamic variables, and you start to erase varaibles in the middle of the array.
Good Luck
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
I have started a Win 32 Console Application with MFC support and I have created a dialog box with two buttons(RUN PROGRAM and EXIT buttons). I have also selected the class for the dialog box and set up the buttons correctly.
My source files and header files have been inserted into the source and header folders but I don't know how to link my RUN PROGRAM button with the main source file in my program.
Also there was a .cpp .rc and .h file already created which when compiled printed out to the screen Hello from MFC! should these files be deleated and replaced with my own.
caoimhin
|
|
|
|
|
Let's say I have a CString that ends in "Desktop". How can I programmatically check to see if it's the "Windows Special Desktop Folder" for the current user? Anyone know?
|
|
|
|
|
put in a function and check against your string
ITEMIDLIST* pidl;
char szPath[MAX_PATH];
HRESULT hRes = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl);
if(hRes == NOERROR)
SHGetPathFromIDList(pidl, szPath);
IMalloc* palloc;
hRes = SHGetMalloc(&palloc);
palloc->Free((void*)pidl);
palloc->Release();
return szPath;
StartMenu = CSIDL_STARTMENU
Programs in StartMenu = CSIDL_PROGRAMS
StartUp = CSIDL_STARTUP
Recents = CSIDL_RECENT
Favourites = CSIDL_FAVORITES
hope it helps
shotgun
|
|
|
|
|
when using multiple dialogs in mfc how do i create then show a dialog without using DoModal(), ShowWindow(SW_SHOW), doesn't work, not initialized i think...
shotgun
|
|
|
|
|
for show window u can use
DoModal() it is a blocking function
ot
Create(resourceID,NULL);
then
.ShowWindow(SW_SHOW)
it will run parallell..
ok?
try it now..
Renjith
Hai Friends me from Pandalam..and i think there is a sofware behind everything...
so enjoy with the codes...
|
|
|
|
|
I write a application with MFC, I using macro UNICODE and _UNICODE, I put wWinMainCRTStartup. But I cann't display Text in EditBox, ComboBox, Button and other control.
Can you tell me about the method or manual to do that?
Thank you!
|
|
|
|
|
I create two splitter wnd, just like:
|
| wnd2
wnd1 |------------
| wnd3
|
I want to min the size of wnd1 and wnd3, that's my code:
m_wndSplitter.SetColumnInfo( 0, 0, 0);
m_wndSplitter.RecalcLayout();
m_wndSplitter2.SetRowInfo(1, 0, 0 );
m_wndSplitter2.RecalcLayout();
after running, wnd1 can be mined, but no effort on wnd3, what's the problem?
I'm amumu, and you?
|
|
|
|
|
This could be a very simple question but could anyone out there help me. I was hoping that there was an easy way to get a program to draw a line from one set of (x, y) coordinates to another set of (x, y) coordinates. I have looked everywhere but have had no joy so please help.
|
|
|
|
|
::MoveTo(..);
::LineTo(..);
Look up these in MSDN!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Docking windows in Win32 without MFC is what I'm currently
coding. I'm doing it this way:
I have Dock bars, which are just frameless gray child windows. The frame
window consists of four of such dock bars and a client window. The frame
window also resizes all these five windows, e.g. the dockbar at the left is
stretched along the y-axis, the dockbar at the upper side is stretched along
the x-axis etc.
Now there are dock windows. These can dock on a dockbar or float. When
floating, they get a toolwindow frame and a popup style. If, for example, I
wanna dock a toolbar, I can do two things:
a) derive a toolbar class from the dockwindow one, or
b) i can make the toolbar a child of the dockwindow.
DockBar itself is responsible for repositioning and/or resizing the docked
dock windows.
To disable the (de)activation of floating windows and the main window, I use James Brown's method (see http://freespace.virgin.net/james.brown7/tuts/docking1.htm). Do you have any suggestions how to solve the docking problem better?
|
|
|
|
|