|
I want to add a logo bitmap, either tiled or centered, behind my document windows so that when they are minimized it displays the logo.
I'm not quite sure how to approach this, any ideas?
: Dean 'Karnatos' Michaud
|
|
|
|
|
This post of mine shows you how.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
What was the date it was written? For some reason the link doesn't forward me onto the post, but I am guessing it has something to do with my job-place's horrible caching server messing things up yet again.
If you could repost it, or point me to the date it was published I might be able to work around this caching server's annoyance.
Thank you for the help!
: Dean 'Karnatos' Michaud
|
|
|
|
|
I guess the problem is you're not using DHTML, and the URL changes with this optio on.
Anyway, here's the post again.
--repost
It's simple task, but many steps are required:- Create a new
CWnd -derived class, say CBackgroundWnd .
- Add these two members to
CBackgroundWnd :
CBitmap m_bitmap_background;
BITMAP m_bmInfo_background; along with this piece of code in CBackgroundWnd ctor:
m_bitmap_background.LoadBitmap(IDB_BACKGROUND);
::GetObject(m_bitmap_background,sizeof(BITMAP),&m_bmInfo_background);
- Add a handler for
WM_ERASEBKGND in CBackgroundWnd and plug this code (which draws the bitmap in tesellation mode)
BOOL CBackgroundWnd::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
GetClientRect(rect);
CDC dcMem;
dcMem.CreateCompatibleDC(pDC);
HBITMAP* pBmpOld=(HBITMAP*)::SelectObject(dcMem.m_hDC,m_bitmap_background);
for(int y=rect.top;y<rect.bottom;y+=m_bmInfo_background.bmHeight){
for(int x=rect.left;x<=rect.right;x+=m_bmInfo_background.bmWidth){
pDC->BitBlt(x,y,m_bmInfo_background.bmWidth,m_bmInfo_background.bmHeight,
&dcMem,0,0,SRCCOPY);
}
}
::SelectObject(dcMem.m_hDC, pBmpOld);
return TRUE;
}
- Add a member of type
CBackgroundWnd to your CMainFrame class, say m_wndClient .
- Override
CMainFrame::OnCreateClient with this:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
if(!CMDIFrameWnd::OnCreateClient(lpcs, pContext))return FALSE;
m_wndClient.SubclassWindow(m_hWndMDIClient);
return TRUE;
} That's it, I think. Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
--end repost
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín , what does it mean "tesellation mode" ? Could you explain ?
Cheers,
Joao Vaz
A person who is nice to you, but rude to the waiter, is not a nice person - Natalie Portman (Padme/Amidala of Star Wars)
|
|
|
|
|
Same as "mosaic mode": the bitmap is repeated horizontally and vertically to cover all the area.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Okay. Thanks
Cheers,
Joao Vaz
A person who is nice to you, but rude to the waiter, is not a nice person - Natalie Portman (Padme/Amidala of Star Wars)
|
|
|
|
|
Man, beautiful! I'm glad I asked, I was taking a different approach and it was causing undeserved headache!
Thanks again Joaquín
: Dean 'Karnatos' Michaud
|
|
|
|
|
Hello.
I want to know the exact location from where my program is launched. The thing is that argv[0] has the full path only when I execute it from the Visual Studio or Explorer. But when I'm using dos shell to execute the file from the current directory, __argv[0] contains only the name of the file
How it can be solved? Thanks for help!
Alexander.
|
|
|
|
|
The GetCurrentDirectory function retrieves the current directory for the current process.
Cheers,
Joao Vaz
A person who is nice to you, but rude to the waiter, is not a nice person - Natalie Portman (Padme/Amidala of Star Wars)
|
|
|
|
|
I'm use the follow code:
CString CMyApp::GetHomeDirectory() const
{
TCHAR sFilename[_MAX_PATH];
TCHAR sDrive[_MAX_DRIVE];
TCHAR sDir[_MAX_DIR];
TCHAR sFname[_MAX_FNAME];
TCHAR sExt[_MAX_EXT];
GetModuleFileName(AfxGetInstanceHandle(), sFilename, _MAX_PATH);
_tsplitpath(sFilename, sDrive, sDir, sFname, sExt);
CString rVal(CString(sDrive) + CString(sDir));
int nLen = rVal.GetLength();
if (rVal.GetAt(nLen-1) != _T('\\'))
rVal += _T("\\");
return rVal;
}
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Eugene Pustovoyt wrote:
CString CMyApp::GetHomeDirectory() const
What's that const there for ?
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
the function doesn't modify the object's internal state therefore, it can be marked "const". users of the class might like to know that.
-c
Cheap oil. It's worth it!
|
|
|
|
|
Thanks Chris!
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Adding to what said Chris, all functions that doesn't change internal state, should marked const , since this could help the c++ compiler to optimize your code.
And of course, it reinforces the idea that the function doesn't affect the internal state of the component/object .
It's part of a filosofy of const correctness concerning the use of const Ref& to all your reference input arguments that wouldn't be modified by the function/method.
Cheers,
Joao Vaz
A person who is nice to you, but rude to the waiter, is not a nice person - Natalie Portman (Padme/Amidala of Star Wars)
|
|
|
|
|
Thanks Joao
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Your welcome
Cheers,
Joao Vaz
A person who is nice to you, but rude to the waiter, is not a nice person - Natalie Portman (Padme/Amidala of Star Wars)
|
|
|
|
|
Thanks a lot! It helped.
And thank you everyone for the help. It is really pleasant when people help you.
Alexander
|
|
|
|
|
Try GetModuleFileName
Best regards,
Alexandru Savescu
|
|
|
|
|
A friend of mine introduced me to this "trick" with the watch window. When watching an HRESULT, you can format the result to something that makes a little more sense.
Here's an example... If I have a variable HRESULT hr; and if I put hr,hr in the watch window it formats the value of hr into text.
So if the hr = 0 the watch window would read "S_OK".
Does anyone know of other cool watch window tricks like this?
TIA
Mark Donkers
A witty saying proves nothing.
-- Voltaire
|
|
|
|
|
You mean something like here:
http://msdn.microsoft.com/library/en-us/vcug98/html/_asug_symbols_for_watch_variables.asp?frame=true
don't you?
And except that, you can use for example ERR, to show last error, instead of calling GetLastError().
Martin
|
|
|
|
|
Martin,
This is perfect! Thanks a million
Mark Donkers
A witty saying proves nothing.
-- Voltaire
|
|
|
|
|
I get the following error "First-chance exception in iss.exe (KERNEL32.DLL): 0xC0000005: Access Violation." with the code below at the statement mlist.GetColumn(i, &lvc);. Could anyone tell me why, I tried a lot of things but I cannot find a cause? Below is the code:
void CAdjustHeaderColumns::SaveColumnHeadingDefaultInfo(CString mCName, CListCtrlEx &mlist)
{
CRegKey reg;
CString g_registry;
g_registry.Format("%s%s", REG_ROOTDIR, COLDIR);
CNewHeaderCtrl* pHeader = (CNewHeaderCtrl*) mlist.GetDlgItem(0);
ASSERT(pHeader);
ASSERT(mlist);
int nMaxHLen = 100;
int mCount = mlist.GetColumnCount();
CString Caption;
CString mNum;
CString mWidth;
CString mCaption;
CString mPrevCaption;
mPrevCaption = "InitialStartUp";
LV_COLUMN lvc;
// Get the Column Info and fill the HDITEM structure
HDITEM HdItem;
HdItem.mask = HDI_TEXT;
HdItem.pszText = Caption.GetBuffer(nMaxHLen);
HdItem.cchTextMax = nMaxHLen;
// Save the default column information to the registry
for (int i = 0; i < mCount; i++)
{
mNum.Format("%d", i);
pHeader->GetItem(i, &HdItem);
mlist.GetColumn(i, &lvc); <--- error occurs here
mWidth.Format("%d", mlist.GetColumnWidth(i) );
m_dpos.Format("%sHDP%d", mCName, i);
m_dwdth.Format("%sHDW%d", mCName, i);
m_dtext.Format("%sHDT%d", mCName, i);
mCaption.Format("%s", Caption);
if (mCaption == mPrevCaption)
mCaption += "2";
if (reg.Open(HKEY_CURRENT_USER, g_registry) == ERROR_SUCCESS)
{
reg.Write(m_dpos, mNum);
reg.Write(m_dwdth, mWidth);
reg.Write(m_dtext, mCaption);
mPrevCaption = mCaption;
}
}
Caption.ReleaseBuffer();
}
Thank-you
Sincerely,
RAH
|
|
|
|
|
Seems you're not setting lvc.mask to any sensible value.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That was the problem. Thank-you very much. I reviewed this code several times and it never occurred to me about the mask. I would never have found this without your help.
Thank-you
Sincerely,
RAH
|
|
|
|
|