|
Joaquin
That can certainly get me an HWND, but then I get lost. I cannot see how to then get a pointer to the window, or get access to the StatusBar via the HWND.
Thank
Tony
|
|
|
|
|
CStatusBar(hParent).SomeFunctionYouCannotLiveWithout();
|
|
|
|
|
In stdafx.h, replace
extern CAppModule _Module; with
template <typename TWnd>
class CMainWindowedAppModule : public CAppModule {
TWnd* m_pWnd;
public:
void SetMainWindow(TWnd* pWnd) {
m_pWnd = pWnd;
}
TWnd* GetMainWindow() {
return m_pWnd;
}
};
extern CMainWindowedAppModule <class CMainFrame> _Module;
And in <YourAppNameHere>.cpp, replace
CAppModule _Module; with
CMainWindowedAppModule <class CMainFrame> _Module;
and don't forget to call SetMainWindow() in Run() before entering the message loop.
Nice and simple if HWND isn't enough. Plus, you can stick other stuff into that class too if you want/need.
--
There's a new game we like to play you see. A game with added reality. You treat me like a dog, get me down on my knees.
We call it master and servant.
|
|
|
|
|
Hehe.. Or you can just make a global variable and be done with it.
(runs and hides)
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Tim Smith wrote:
Hehe.. Or you can just make a global variable and be done with it.
That would be too easy. Remember, I'm a programmer. I love complexity.
--
There's a new game we like to play you see. A game with added reality. You treat me like a dog, get me down on my knees.
We call it master and servant.
|
|
|
|
|
Tim Smith wrote:
Hehe.. Or you can just make a global variable and be done with it.
(runs and hides
It's all right Tim - I've got a colleague who suggested just the same thing. He ran away too, just before my copy of "ATL Internals" hit the wall where he had been standing!
Tony
|
|
|
|
|
*snicker*
Be careful though. You don't want to ruin your favorite books now do you?
--
Eventhough the forrest is full of trees, there's still no tree between the trees.
|
|
|
|
|
he he. Cool. I do something similar using the following class:
class CMainFrame;
class CParentFrame
{
private:
CMainFrame* m_pMainFrame;
public:
CParentFrame() : m_pMainFrame(NULL)
{
}
CMainFrame* GetMainFrame() const { ATLASSERT(m_pMainFrame != NULL); return m_pMainFrame; }
void SetMainFrame(CMainFrame* pFrame) { m_pMainFrame = pFrame; }
}
I then derive each view from CParentFrame, remembering to call the "SetMainFrame" function when I create the view. The view can then call GetMainFrame()->Blah() , etc.
When I am king, you will be first against the wall.
|
|
|
|
|
Here's one technique to update the status bar from a child window. It only supports the first pane, though.
HWND hWnd = ::GetDlgItem(GetParent(), ATL_IDW_STATUS_BAR);<br />
CStatusBarCtrl sb = hWnd;<br />
sb.SetWindowText(_T("My status bar text"));
Note that GetDlgItem obtains the handle of any child window as long as the child was created with a defined ID such as ATL_IDW_STATUS_BAR. Default WTL IDs are defined in atlres.h.
|
|
|
|
|
If I have a vector:
std::vector<CMyClass>m_vMyVector;
And in a function I do:
foo()
{
CMyClass obj;
m_vMyVector.push_back(obj);
}
When obj goes out of scope, will a copy still live in m_vMyVector?
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Nitron wrote:
When obj goes out of scope, will a copy still live in m_vMyVector?
Yes
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
thanx!
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
|
When building some ATL projects that we're upgraded to version 7.0 of the Visual C++ compiler; the post build regsvr32 step always fails. I have tracked this down to the binary not being created before regsvr32 is called.
In the post build step we have
regsvr32 /s /c "$(TargetPath)"
Has anybody seen this? If so how did you fix it. Thanks in advance.
-chad
|
|
|
|
|
It's most likely something in the registration code within the DLL that is the error. Chances are that it's segfaulting.
--
There's a new game we like to play you see. A game with added reality. You treat me like a dog, get me down on my knees.
We call it master and servant.
|
|
|
|
|
Hi,
I can't get bitblit to work with WTL. It keeps printing a black square. But the size of the square is equal to the size of the image it should print so i think i'm forgetting something. I'm converting my Win32/SDK app to WTL and in Win32/SDK it works. This is the code i'm using:
<br />
CBitmap Image;<br />
Image.LoadBitmap(238);<br />
<br />
CPaintDC dc(m_hWnd);<br />
CDC hdc;<br />
hdc.CreateCompatibleDC(dc.m_hDC);<br />
<br />
BITMAP Temp;<br />
Image.GetBitmap(&Temp);<br />
SelectObject(hdc.m_hDC,&Temp);<br />
dc.BitBlt(50,50,Temp.bmWidth,Temp.bmHeight,hdc,0,0,0);<br />
I tried making a filledrect with the same DC object and it worked. Thanks for all help.
|
|
|
|
|
modify the line to :
SelectObject(hdc.m_hDC,Image);
|
|
|
|
|
Doesn't seem to help. It keeps blitting an empty (black) surface to my screen...the size is correct though so the loading prolly is ok....
Anyone?
|
|
|
|
|
Try replacing:
Tommy2k wrote:
BITMAP Temp;
Image.GetBitmap(&Temp);
SelectObject(hdc.m_hDC,&Temp);
dc.BitBlt(50,50,Temp.bmWidth,Temp.bmHeight,hdc,0,0,0);
with something like:
HBITMAP hOldBitmap = hdc.SelectBitmap ( (HBITMAP) Image );
SIZE dim;
Image.GetBitmapDimension ( &dim );
dc.BitBlt ( 50, 50, dim.cx, dim.cy, (HDC) hdc, 0, 0, SRCCOPY );
dcBW.SelectBitmap ( hOldBitmap );
cheers,
-B
|
|
|
|
|
Thanks, i works now
|
|
|
|
|
Ok I hope this is a stupid question. How do you lock STL stream files such as ostream, so other processes can't access them. ie. I want the functionality that CreateFile( ..., FILE_SHARE_READ etc. ) offer. When I open a file to write to it, I want to ensure no other apps/processes can open it untill I'm finished with it. I can't see any options to let me do this with STL streams. Surely I'm missing something here.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Could you find any solution?
Thank You
|
|
|
|
|
Soni wrote:
Could you find any solution?
No, do you have one?
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Hi All,
I am new to COM and ATL and have written a short console app in an attempt to learn ATL's Database access techniques. My app creates an Accessor class, CDataSource object, CSession object and CCommand object. I am sucessfully able to get and display info from the database. The ATLDB objects are closed and CoUninitialized is called. Everything seems fine until COM is uninitialized. That is when I get the following error ... Unhandled exception in oleDB.exe: 0xC0000005 Access Violation. I am not sure what exception to catch or why it is happening. Like I said I am new to COM and ATL, maybe someone has a simple answer. If necessary I can post the code.
Thanks
Paul
|
|
|
|
|
Got it!!!
It's amazing what a couple of braces will do. By putting the COM objects in a block, the destructors are guaranteed to be called befor CoUninitilize().
|
|
|
|