|
Doesn't matter that the dialog is modal or modalless, the program can only execute the commands one at a time (one THREAD of execution). For situations where you need to keep the interface going while the background is doing some immense operations, you would most likely want to use another thread (see MSDN CWinThread) to perform the background operations. Then in your background thread, occastionally stop processing (Sleep() or MSDN WaitForSingleObject()) to allow the UI thread to process.....
|
|
|
|
|
Does that mean you've fixed it, or just found the problem ?
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
Is the ON_WM_TIMER() macro in the message map of your class?
|
|
|
|
|
I've made an application and I cannot change the icon created when the program saves a file. I have edited the icon (IDR_...TYPE) in the resources, change it and recompiled it, but the program always creates the default doc icon. What could be the problem?
|
|
|
|
|
I think you not only have to edit the resources, but also you need to define and initialize in the "OnDraw" function.
|
|
|
|
|
Do you mean the icon seen from Explorer, or when the DOC is open in the App?
1. From Explorer - You have to create an association between your App and the file type
2. In your App - Just create a new icon, and name it whatever the icon file is named in your App/Res directory. Overwrite that icon with the new one, and it will display properly.
|
|
|
|
|
OK,
I've got an SDI app. with some splitters in it, a treeview and a listview, I want to be able to drag and drop from one to another. What's the best way to go about this? I've never done any drag & drop before in any language, so all of this is new, any hints are welcome. I've had a look through some of the demo code available on this site, it all seems overly complex, I don't need to accept files from external apps, or send to them, all drag and dropping is limited to my split views.
Tips anyone?
TIA
Jon
|
|
|
|
|
Hi all,
I've succeeded in adding all sorts of sliders and edit controls into toolbars. Now I'm trying to add some CButtons and it isn't working - the toolbar still shows the separator and no CButton.
Do CToolBars not allow CButtons? Is there a way to find out which controls are allowed and which aren't?
thanks,
Jake
|
|
|
|
|
Alright, I got that working Sorry, and thanks anyway.
|
|
|
|
|
I have a list class list<cmyclass> from which I have declared a typedef for the iterator. list<cmyclass>::iterator myIterator;
problem is, i cannot seem to cast myIterator to anything, not even to a variable of type CMyclass*. I need to cast the iterator to a DWORD so that I can store it in an MFC LVITEM struct for later use. I have no problem whatsoever if I use a vector instead of a list! I can happily cast away my vector iterator to a DWORD or LPARAM or even a CMyclass*.
Whats the deal?
Thanks in advance, BTW i am using VC 6.0 sp 5 and I have applied the latest dinkumware patches to my STL.
|
|
|
|
|
I have used a STL list in the manner you discribe.
Perhaps a snippet of the code would allow us to see what you are doing and why it isn't working for you.
|
|
|
|
|
Vector iterators are often ordinary pointers, but you can't trust on that. There's absolutely no guarantee that an iterator will fit in a DWORD or a void*.
|
|
|
|
|
The *address* of the iterator should fit nicely into a DWORD, or for that matter a void*. Of course, you have to cast away the type.
|
|
|
|
|
you can follow this scheme:
* use vector instead of list
* store the index instead of an iterator (this will fit in a DWORD)
* add a constructor to myIterator taking as argument the index, like this
myIterator(DWORD index):
list::iterator(begin()+index)
{}
I hope you get the point, just fill in the details. Good luck
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks but this approach will not work for me. I am currently using a vector and I need to use a list instead. Primarily because I am deleting and inserting (and moving) elements of my container. Iterators become invalid in a vector if you insert anywhere but the end. A list will meet my needs, If I can find a way to store the address of the iterator in my LVITEM struct.
|
|
|
|
|
If you have a vector<t>, then a derefenced vector<t>::iterator is T.
BUT ...
If you have a list<t>, then a dereferenced list<t>::iterator is not T, but rather an object that would look like the following:
class ListNode
{
T* pNextObj;
T data;
...
}
So this is a safety thing on the part of the list implementors to keep you straight -- if you casted to change type, you could not get back the original object again (because this is internal to each STL implementation).
However, given the following code, this would work:
list<int> l;
l.push_back(1);
DWORD dw = (DWORD)(&l.begin());
Then if I want to print the list entry,
typedef list<int>::iterator ListIntIter;
ListIntIter* pi = (ListIntIter*)dw;
cout << **pi << endl;
Alternatively, you can store the index of the iterator and then use STL's 'advance' algorithm.
One more note: I actually consider all of this slightly dangerous, because while you can hold an address to a list element, remember that the size and order of the list could change if you are performing other list operations in the meantime. If you are holding onto iterators because you always want to keep track of, say, the 3rd element, then remember that although the iterator itself will not change in a list, its overall position in the list may still shift. In this case, if you are always wanting the nth element, I would use 'advance' or switch back to a random access container like vector or deque.
|
|
|
|
|
Hi,
I'm trying to open a dialog window in a console application (Using MFC in a shared DLL).
I'm just interested in window to draw on. No dialog items and so on.
Also, I cannot use resources as this will be a utility class for displaying images in console applications.
Using some old code as reference, I managed to do it in a C-style win32 way using a messgage handler with switch/case and threads and using DialogBoxIndirectParam().
I was wondering how I can do it in a more OO way using CWnd message handler mapping, to automatically handle any drwing or other window events.
How do I get the window to show? How do I initialize it?
Thanks a lot,
Adi
PS,
While on the subject, if I have a class with resources.
How can I use this class (as a linked library) in other application, without manually adding its resources to the new project?
Thanks.
|
|
|
|
|
Hi everone,
Can I override some function(s) to customize the minimize button, that is the WM_MINIMIZEBOX?
Is it also possible to add a new button in the title bar?
|
|
|
|
|
You'll have to handle WM_NCPAINT. DrawFrameControl can help in button drawing. This was discussed once in MSJ, search your VC++ help for ShadeCap.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi ,
As far as I understand function TransparentBlt isn't supported in Win95
and some versions of NT. Not just that : it needs msimg32.dll and as I've
heard causes some memory and resources related problems.
What I need is function
BOOL MyTransparentBlt (
HDC hdcDest, // handle to destination DC
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
int nWidthDest, // width of destination rectangle
int hHeightDest, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXOriginSrc, // x-coord of source upper-left corner
int nYOriginSrc, // y-coord of source upper-left corner
int nWidthSrc, // width of source rectangle
int nHeightSrc, // height of source rectangle
UINT crTransparent // color to make transparent
);
That will work under Win95 and won't cause problems. I need
just this only function ( source ) - don't want to deal
with "msimg32.dll"
I'll appreciate Your help,
Thank You
|
|
|
|
|
This is what U need
void MyTransparentBlt( HDC hdcDest, int nXDest, int nYDest, int nWidth,
int nHeight, HDC hBmpDC/*, HBITMAP hBitmap*/, int nXSrc, int nYSrc,
COLORREF colorTransparent, HPALETTE hPal)
{
HDC hdcMask = ::CreateCompatibleDC( hdcDest );
HDC hdcTmp = ::CreateCompatibleDC( hdcDest );
HBITMAP bmMask = ::CreateBitmap( nWidth, nHeight, 1, 1, NULL );
HBITMAP hOldMaskBitmap = (HBITMAP)::SelectObject( hdcMask, bmMask );
HBITMAP hTmpBmp = CreateCompatibleBitmap(hdcDest, nWidth, nHeight);
HBITMAP hOldTmpBmp = (HBITMAP)::SelectObject(hdcTmp, hTmpBmp);
::BitBlt(hdcTmp, 0,0,nWidth, nHeight, hBmpDC, nXSrc, nYSrc, SRCCOPY );
::SetBkColor( hdcTmp, colorTransparent );
::SetTextColor( hBmpDC, RGB( 0, 0, 0 ) );
::BitBlt( hdcMask, 0, 0, nWidth, nHeight, hdcTmp, 0, 0, SRCCOPY );
HDC hdcOffScr = ::CreateCompatibleDC(hdcDest);
::SetBkMode(hdcOffScr, TRANSPARENT);
HBITMAP hbmOffScr = ::CreateBitmap(nWidth, nHeight,
(BYTE)GetDeviceCaps(hdcDest, PLANES),
(BYTE)GetDeviceCaps(hdcDest, BITSPIXEL),
NULL);
HBITMAP hbmOldOffScr = (HBITMAP)::SelectObject(hdcOffScr, hbmOffScr);
::BitBlt(hdcOffScr, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, SRCCOPY);
::SetBkColor( hBmpDC, RGB( 0, 0, 0 ) );
::SetTextColor( hBmpDC, RGB( 0xff, 0xff, 0xff ));
COLORREF crOldBackColor = ::GetBkColor( hdcDest );
COLORREF crOldTextColor = ::GetTextColor( hdcDest );
::SetBkColor( hdcOffScr, RGB( 0xff, 0xff, 0xff ) );
::SetTextColor( hdcOffScr, RGB( 0, 0, 0 ) );
::BitBlt( hdcOffScr, 0, 0, nWidth, nHeight, hBmpDC, 0, 0, SRCINVERT );
::BitBlt( hdcOffScr, 0, 0, nWidth, nHeight, hdcMask, 0, 0, SRCAND );
::BitBlt( hdcOffScr, 0, 0, nWidth, nHeight, hBmpDC, 0, 0, SRCINVERT );
::SetBkColor( hdcOffScr, crOldBackColor );
::SetTextColor( hdcOffScr, crOldTextColor );
::SetBkMode(hdcDest, TRANSPARENT);
::BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcOffScr, 0, 0, SRCCOPY);
if ( hOldMaskBitmap )
::SelectObject( hdcMask, hOldMaskBitmap );
if ( hbmOldOffScr )
::SelectObject( hdcOffScr, hbmOldOffScr );
if ( hOldTmpBmp )
::SelectObject( hdcTmp, hOldTmpBmp );
::DeleteObject( hTmpBmp );
::DeleteObject( bmMask );
::DeleteObject( hbmOffScr );
::DeleteDC( hdcOffScr );
::DeleteDC( hdcTmp );
::DeleteDC( hdcMask );
}
but with more effort you could do your self(msdn etc), like I did it is a lot more fun !!
good luck,
Dror
|
|
|
|
|
I've not tested the code someone else just offered, but I notice it failed to allow for a differering source and destination size. I don't even have the code here, but the Sept issue of WDJ will have an article from me on doing exactly what you want, and also alphablend under W95. Basically to change the code below you just need to do a stretchblt to change the source bitmap to the dimensions of the destination.
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
It seems that when I dynamically create my radio button (i.e at run time) the text gets displayed if I choose certain UID number and not the other ones.
m_RadioButtonArray[nDex].Create("paradi",
WS_GROUP | WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON , ctrlRect,this, 2013 );
Note that on this screen I am also dynamically creating other edit controls that their GUI ID ranges from 1999 to 2011 !!!!
Paradise is where I am.
Voltaire
|
|
|
|
|
anyone knows how to convert an int variable from decimal to hex?? I am using VC++ and MFC, but am looking for a simple function to do it.
please reply to me at asengupt@uiuc.edu
Thanks!
ananya
(student)
|
|
|
|
|
If you want to print it use something like printf, or use _ltoa or _ultoa.
|
|
|
|
|