|
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
|
|
|
|
|
I have set up an application made of two CFormView based Forms.
I took as an example the Enroll Database Sample provided with Visual Studio.Net.
In the firs form the user can query the Database, the records are displayed in a ListControl.
After I want that when the user doubleclick a record in the list, or press a Button "Select", in the second form he can edit and update the record selected.
The second form consists of an edit control for each field in the database.
So when the user select a record in the first form, I query the database, I put with CEdit.SetWindowText() each field in the edit controls in the second form, and if the user make any change in the second form, I Update the database.
THE PROBLEM IS:
I have two different classes CFirsForm and CSecondForm.
In the OnBnSelectClick() in the First class how I call the member variables contained in the second class m_edit1, m_edit2, etc.
The code should look like:
CDataForm *pData;
pData = new CDataForm;
pData->m_editAddress.SetWindowText("st James Street");
delete pData;
But I get a Debug Assertion Failed, winocc.cpp Line:247.
What's wrong?
Sorry my incompetence.
"Nelle cose del mondo non e' il sapere ma il volere che puo'."
|
|
|
|
|
laphijia wrote:
CDataForm *pData;
pData = new CDataForm;
pData->m_editAddress.SetWindowText("st James Street");
delete pData;
Aren't you deleteing the form too soon?
And when exactly does the error occur?
Best regards,
Alexandru Savescu
|
|
|
|
|