|
How can I change the title of a sdi application?
I used CDocument->SetTitle() - doesn't work (nothing changes)
used CMainFrame->SetWindowText - but this crashes my app (Unhandled exception - memory violation - as It got a NULL pointer, when i debugged, inside the MFC function SetWindowText, there was an ASSERT(::IsWindow(m_hWnd)), but this(==m_hWnd) was equal to NULL, so that is why there was memory violation ...
used m_pszAppName (changed it) and nothing changes ...
heard about taking care of OnUpdateFrameTitle, but this method is not a member of frame, or document, but an ole class ...
used many other strange ways, and did not succeed ...
Anyone having an idea ?PLZ
|
|
|
|
|
Where abouts in your code were you changing the window title via the CMainFrame::SetWindowText. It sounds like you were trying to do it before the window was created.
Michael
|
|
|
|
|
Inside the CDocument constructor, I wanted to change the title bar, when the document changes in some way... and I call a function (which calls CMainFrame::SetWindowText() ) from CDocument's constructor, and if this constructor is called when the frame doesn't exist, that is the answer... hey, thank you, I hope that is the case
|
|
|
|
|
I pulled this example from Michael Dunn's Article at http://www.codeproject.com/listctrl/lvcustomdraw.asp... I'm lost
how do I repaint the headder instead of items?
void CMyDlg::OnCustomdrawMyList ( NMHDR* pNMHDR, LRESULT* pResult )
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = CDRF_DODEFAULT;
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
COLORREF crText;
if ( (pLVCD->nmcd.dwItemSpec % 3) == 0 )
crText = RGB(255,0,0);
pLVCD->clrText = crText;
*pResult = CDRF_DODEFAULT;
}
}
Thanks,
Rob
|
|
|
|
|
I have not actually done this before, but the header is a different control, so I don´t think you should use the custom draw of the list. CHeaderCtrl supports custom draw (search for the term in MSDN), writing a separate handler for its NM_CUSTOMDRAW should allow you to format the header.
Hope this will set you in the right direction.
/moliate
|
|
|
|
|
I'm looking for some useful explanations of the Memory resources displayed in WIn9x System Monitor (under Accessories); esp.
reserved memory (mostly but not always correlates to swap file usage + Physical memory used)
Do you know any article, web site etc. that does explain some deeper things about the memory managment?
(I'm combatting some weird memory hog... no fun)
TIA Peter
|
|
|
|
|
Hi,
I am using GDI+ to convert a batch of TIFFS to JPEGS - i was just wondering how i can resize a image object and then save it out. Does it have to go via a 'graphics' object? and if so how?
Cheers
Richard
|
|
|
|
|
Yes, you can resize it by drawing it onto a graphics object of the right size, making sure you stretch it at the same time. The best function in my opinion for this is Graphics::DrawImage.
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
|
|
|
|
|
Hi,
I (desperately) need a list of running processes (ID orHandle, and Module name), on Win 9x (more important) and NT/W2K. I know I know this gets asked often, but couldn't find any on CP..
Thanks a lot!
Peter
|
|
|
|
|
I think there is a sample in the platform sdk, PViewer or something like that. So a search on MSDN for Process Viewer.
Michael
|
|
|
|
|
http://www.codeproject.com/threads/interprocesssync.asp
--------------------------------------------------
If my messages appear curt, I apologize.
I try to be brief to save your time as well as mine.
--------------------------------------------------
|
|
|
|
|
MSDN Search:
HOWTO: Enumerate Applications in Win32
Q175030
The information in this article applies to:
Microsoft Win32 Application Programming Interface (API), used with:
the operating system: Microsoft Windows NT, version 4.0
Microsoft Windows 95
the operating system: Microsoft Windows 2000
Definitely one of the best starting points to do it.
|
|
|
|
|
Use CreateToolhelp32Snapshot, Process32First and Process32Next defined in tlhelp32.h. It works on Win9x as well as NT (PSAPI gives you more control, but only works on NT).
/moliate
|
|
|
|
|
Actually, ToolHelp32 funtions are *not* available on NT4, according to MSDN. W2K supports them, however.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Sorry, my mistake...
Thanks for the info.
/moliate
|
|
|
|
|
Thanks folks! (Yes I'm a bit late, just didn# get notifs)
I went with the ToolHelp23 functions, since Win98 and W2K are enough and NT4 isn't *that* important.
Peter
|
|
|
|
|
I'm writing an application that opens bitmaps and then let user make a
selection by drawing a dragging rectangle with mouse. I'd like that drawn
rectangle does not disappear on mouse-left-button-up event, but only on next
button-down event.
Someone could tell me how this code doesn't work? Or may suggest me some
right code, please?
// m_bDrag, m_bDraw, m_bEraseRect are boolean initally set as FALSE by
constructor
void CFotoView::OnLButtonDown(UINT nFlags, CPoint point)
{
SetCapture();
m_bDrag = TRUE;
CClientDC dc(this);
if(m_bEraseRect)
{
dc.SetROP2(R2_NOTXORPEN);
dc.Rectangle(m_ptFirst.x, m_ptFirst.y, m_ptLast.x, m_ptLast.y);
m_bEraseRect = FALSE;
}
m_ptFirst = point;
CScrollView::OnLButtonDown(nFlags, point);
}
void CFotoView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(m_bDrag)
{
if(nFlags)
{
m_bDraw = TRUE;
m_ptCurrent = m_ptNew = point;
//ClientToScreen(&m_ptCurrent);
//ClientToScreen(&m_ptNew);
m_bDrag = FALSE;
}
}
else if(m_bDraw)
{
CClientDC dc(this);
dc.SetROP2(R2_NOTXORPEN);
dc.Rectangle(m_ptCurrent.x, m_ptCurrent.y, m_ptNew.x, m_ptNew.y);
m_ptNew = point;
//ClientToScreen(&m_ptNew);
dc.Rectangle(m_ptCurrent.x, m_ptCurrent.y, m_ptNew.x, m_ptNew.y);
}
CScrollView::OnMouseMove(nFlags, point);
}
void CFotoView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(m_bDraw)
{
CClientDC dc(this);
m_bDrag = FALSE;
m_bDraw = FALSE;
ReleaseCapture();
dc.SetROP2(R2_NOTXORPEN);
//ClientToScreen(&point);
//dc.Rectangle(m_ptCurrent.x, m_ptCurrent.y, m_ptNew.x, m_ptNew.y);
m_bEraseRect = TRUE;
m_ptLast = point;
}
else if(m_bDrag)
{
m_bDraw = FALSE;
m_bDrag = FALSE;
ReleaseCapture();
}
CScrollView::OnLButtonUp(nFlags, point);
}
Thanks everyone could help me.
Bye
giampy
|
|
|
|
|
you are probably overwriting the rectangle in your OnDraw call. in general, you should try to handle all drawing from your OnDraw. every other function should just Invalidate the parts of the view that it wants redrawn. there are execptions to this rule, of course; but this is a good way to start.
-c
POKE 808,234
|
|
|
|
|
YOU'RE RIGHT!!!
I followed your precious hint and now it works!
Thx: this really helped me!
giampy
|
|
|
|
|
If you haven't looked at it already, take a look at the CRectTracker class. The documentation suggests that it's intended for OLE/COM, but in reality it's much more general than that and makes it pretty easy to do what you describe wanting.
|
|
|
|
|
Hi, All!
=======
Is there any way for me to create an operator.
For example, like the 'new' operator:
Instead of: x= new int[5];
It will be: x= MyNew int[5];
NOT : x= MyNew(sizeof(int)*5) ;
BTW: come to #CodeProject on DalNet (mIRC)
|
|
|
|
|
do a google search on "override operator new". i got 4900 hits. at least the first three pages all looked relevant.
-c
POKE 808,234
|
|
|
|
|
Look up operator new on MSDN.
Michael
|
|
|
|
|
|
I have a program where I need to replace the Alphabet value to numers.
Examples:
I have B13 which has to be replace with 1013.
10 is just aplhabet count. I would know the position in the string to replace.
Please help me.
|
|
|
|