|
I was wondering how I go about changing the background color of a View in a WTL application. I have a handler to WM_ERASEBKGND and my code breaks into the OnEraseBkgnd function but it seems that the code is just ignored.
LRESULT OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
CBrush br;
CClientDC dc(m_hWnd);
br.CreateSolidBrush(RGB(30,30,30));
CRect rect;
GetClientRect(rect); // Using this because
//dc.GetClipBox(rect); // this usually comes back empty.
dc.PatBlt(rect.left, rect.top, rect.Width(),
rect.Height(), PATCOPY);
bHandled = true;
return 0;
}
Cheers,
Clint
|
|
|
|
|
I'm using OnCtlColor event to paint the dialog background.
HBRUSH CMyClass::OnCtlColor(CDC* pDC,
CWnd* pWnd,
UINT nCtlColor)
{
switch (nCtlColor)
{
case CTLCOLOR_BTN:
case CTLCOLOR_STATIC:
pDC->SetBkMode(TRANSPARENT);
break;
case CTLCOLOR_DLG:
{
if (m_pBrush)
delete m_pBrush;
m_pBrush = new CBrush(m_dwCorBkgDlg);
return (HBRUSH) (m_pBrush->m_hObject);
}
}
return(CDialog::OnCtlColor(pDC, pWnd, nCtlColor));
}
and it's working well.
[]'s
|
|
|
|
|
I am not using a dialog. I am just using your standard doc/view default where the view is white and the surrounding document is windows standard. I am not sure how I would use this in my case.
Cheers,
Clint
|
|
|
|
|
Btw is there a way to make this work?
<cpp>
#define REPEAT( TYPE, DIM, I ) \
#if ( I == 0 ) \
#( \
#endif \
#const TYPE& + rv#ii \
#if ( I < DIM - 1 ) \
#, \
REPEAT( TYPE, DIM, I + 1 ) \
#else \
#) \
#endif \
The idea is
if we have REPEAT( double, 3, 0 )
to get as result
"const double& rv0, const double& rv1, const& rv2"
|
|
|
|
|
1) I can't tell what you're trying to do.
2) If it's this complex, make it a function instead of a macro. If the type is unknown, overload the function for the expected types.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
You can't perform stuff like this with preprocessor macros. what do you want to achieve?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
The idea is following:
I have containers like
template< class T >
struct TSPACE3
{
TSPECE3( T x, T y, T z, T w );
T x;
T y;
T z;
};
template< class T >
struct TSPACE4
{
TSPECE4( T x, T y, T z, T w );
T x;
T y;
T z;
T w;
};
and vector like
template< class T >
class TVector : public T
{
};
typedef TVector< TSpace3<double> > Vector3d;
typedef TVector< TSpace4<float> > Vector4f;
So now if I make a instance of these objects, I would like to use constructors of TSpace, without to define them into TVector, also I don't want to make ctor like
TVector( T& x,...)
Usage
Vector3d v3d( 1, 0, 3 );
Vector4f v4f( 1.0f, 2.3f, 4.4f, 3.4f );
Some kind of "inherited" the ctor of TSpace
|
|
|
|
|
Assuming that your REPEAT macro works, how would you use it to solve this problem?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
So what you really want is a way to initialize the elements to a specific set of values? You can do that with a custom allocator or if it's just for a single element then you can just use an init function.
Todd Smith
|
|
|
|
|
No you can't do that.
<soap box=""> And besides it's unreadable to another programmer.
However, you could do
#define REPEAT( TYPE, DIM, I ) const TYPE& rv[DIM];
and then use another macro for accessing the elements
instead of rv0 it would be rv[0]
Todd Smith
|
|
|
|
|
The problem is that you'd have to initialize the array of references...
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
hi folks -
Background: My super-duper heavily multi-threaded app is suffering from an intermittent, and partially random, memory leak somewhere deep in the inner workings of a thread-safe multi-source/single-sink logging mechanism. On exit, as everybody knows, the MSVC runtime prints out the addresses, and first 16 characters(actually 'MAXPRINT' -- see crt/src/dbgheap.c), of all unfreed memory blocks. Unfortuantely, this isn't enough for me to pinpoint the source of the leak, so I need to recompile MSVCRTd.DLL with an increased value for MAXPRINT. Several hours this morning spent attempting to reconstitute the missing MSVCRTD makefile, followed by an almost-successful binary patch of the DLL have both failed to do work properly.
Does anybody have a makefile, or a procedure to build this DLL?
ta,
- robin.
|
|
|
|
|
No BoundsChecker or Purify at hand? They will give you much better diagnostic information.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I don't have an answer to your question. However, I'm curious as to why you can't figure out the source of the memory leak. I mean, usually when DevStudio spews out the memory leaks it also gives you the file and line number where the allocation took place. If you're not getting that, then it's probably because you haven't defined new to DEBUG_NEW at the top of your cpp files, like this:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
Make sure all your cpp files have this at the top, after your includes. That should clear things up a bit.
Regards,
Alvaro
|
|
|
|
|
Does anyone know of any good sites with Pocket PC / Windows CE code snippets / samples?
Although Code Project is great for most things - it is a little light on specific CE issues.
|
|
|
|
|
I'm trying to save/restore the size and position of multiple views in an MDI.
Here is my dilema in it's simplest form. When I open a new child window by default I call:
CRect rect;
CFrameWnd* pParentFrame = GetParentFrame();
CWnd* pMDIClient = pParentFrame->GetParent();
pMDIClient->GetClientRect(&rect);
pParentFrame->MoveWindow(0,0,450,430);
which sets the size and location of my window. so then I try to save it by calling in the specific view:
GetWindowRect(&rect); but top = 163, bottom = 572, left = 3, right = 551;
and
GetWindowPlacement(&wp); but top = -3, bottom = 406, left = -3, right = 445
I would expect to receive top =0, bottom = 430, left =0, right = 450 since that's where I moved it.
Any ideas? Thank you
|
|
|
|
|
GetWindowRect is returning co-ordinates relative to the screen, and MoveWindow has positioned it relative to the parentframe. Call GetwindowRect and then call pPArentFrame->ScreenToClient to normalise the co-ordinates relative to that window.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Am looking into writing a small application to be run on a Pocket PC and I have requirement to stop the user of the Pocket PC use anything other than the application. I.e. I need to stop them getting to the apps like Inbox, the start menu etc.
In the WM_INITDIALOG of my app, I have added the following.
SHDoneButton(this->m_hWnd, SHDB_HIDE);
SHFullScreen(this->m_hWnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON);
On running, the application is full screen - but the Start Menu is still there.
My device hasn't got a physical keyboard - If I had one of those would I need to prevent ALT-TABBING as well ?
One suggestion that I've had is that this isn't possible in Pocket PC and I'd have to get Platform Builder out and make my own version of CE - which sounds really scary ? Is this on the right lines ?
All help much appreciated.
|
|
|
|
|
Hi im trying to read a string in that format from a file (with sprintf)
asdf| hello| dee|
if i use (buf1 & buf2 are char[50])
sprintf( filestream, "%s%s",buf1, buf2), in buf1 i get "asdf|" and in buf2 i get "hello|".
But i want to use the "|" as the string delimiter. So i wrote:
sprintf( filestream, "%[^|]%[^|]",buf1, buf2)
With that function, i can only get buf1 correct but i get nothing for buf2.
Anyone has an idea of what is the problem?
thanks
|
|
|
|
|
Your snippet of code is confusing: sprintf will format a string based on your pattern ("%s%s"), and put it in the filestream string.
Surely you're using sscanf?
I'd consider using a combinateion of CString member functions, like CString::Mid and FInd and stuff
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Sorry, your right! im using fscanf
Thankx for the correction Jon
|
|
|
|
|
I posted an article about parsing CStrings. Check it out here.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
Hi,
Is there any good and fast way to print reports using Visual C++, ... using GDI and printing cannot be very proffesional looking, and add my own code for all the stuff it´s like crazy...
I have thought to use Word Automation, but that mean to have a program not so stable, and very slow... ( I mean if you have an EXE of Word running that is corrupted, then you can not print until you take the task manager and delete it ( quite intiutive for the user), and it takes a while to load Word to export and print a little thing...).
So can anybody help me ? ( I´m searching for free things to use, not magic controls that cost a lot of money ).
Thanks, Bye !
Braulio
|
|
|
|
|
In actual fact, using GDI to print can produce extremely professional results. Word itself uses GDI to do printing, as doo all other Windows applications, either directly or indirectly (i.e. through a class library, DLL, or COM object).
--
Andrew.
|
|
|
|
|
Hi !,
Yes, with GDI you can make a lot of nice stuff, but it takes some more extra time, ... if you need to print 10 standard reports... just looking for an ActiveX or whatever in which you pass the recorset, and Header, and you have it all done...
I can try to make a class like that for me, but I don´t like to reinvent the wheel..., and it´s sure that it won´t look so proffessional, because to make such thing quite, quite ok, you need some time to do it.
Bye !
Braulio
|
|
|
|
|