|
Rome Singh wrote:
Should it be "thoughts YOUR aim"?
and it's been like that for almost 18 months,
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Hi! I have a little problem
When running my mfc mdi app, I get that message from the debugger whenever my cursor flyes over certain toolbar buttons. Next to the ID, apears the buttons identifier
Those buttons have an update message handler (CCmdUI stuff) directly linked with the current CView, so their state change as you switch between views, depending on the view internal state. Buttons without update handlers don't show that behaviour
What that does the message exactly mean? On the other side, the app works ok, so it's a bit strange. I surfed the web, but no infor related to this was found.
Thanks in advance to all.
|
|
|
|
|
That's the application framework letting you know that you haven't defined a fly-by message and tooltip for the toolbar button's id. To fix the problem, define a string resource (with the toolbar button's id) of the following form:
"Command description\nTooltip" /ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hello,
I attach a "TREE CONTROL" in VC++.net, and add a parent and some child nodes.
It works well.
Now i want that, When i click on 1st Child, it display a Message Box with a text, "You clicked on 1st Child".
And when i click on "Second Child", it prints in a Message Box "You Clicked" on 2nd Child.
Kindly help me, that how can i do this.
Regards,
Eshban
EsHbAn BaHaDuR
|
|
|
|
|
The message TVN_SELCHANGED is generated when the selection in the tree control is changed. It gives you a pointer to the item structure which the user selected.
To capture the TVN_SELCHANGED message in MFC, write the following code inside the BEGIN_MESSAGE_MAP and END_MESSAGE_MAP macros located in the window class that is the parent for the tree control:
ON_NOTIFY( TVN_SELCHANGED, tree-ctrl-id, OnSelChanged ) Then add a member function to the class like this:
afx_msg void OnSelChanged( NMHDR * pNotifyStruct, LRESULT * result ); Then write the following skeleton for the handler function:
afx_msg void memberFxn( NMHDR * pNotifyStruct, LRESULT * result )
{
NMTREEVIEW* pTreeView = dynamic_cast<NMTREEVIEW*>( pNotifyStruct );<DIV>
CString strNodeName( pTreeView->itemNew->pszText );
} If you need to identify the items based on their ID, you need to originally store this ID as the lParam value in the TVITEM structure. It can be an integer, for example. When you store it there, you can use the itemNew pointer to get it via the lParam member . An example as follows:
pTreeCtrl->InsertItem( TVIF_PARAM | TVIF_TEXT, _T("Child node 1"), 0, 0, 0, 0, 1, hParentNode, NULL );<DIV>
int ID = (int) pTreeView->itemNew->lParam; I hope this will help you. If you have further questions/problems, post them here.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I'm having problem getting double buffering to work in MFC.
I have tried to implement it based on the information found on this page http://codeproject.com/gdi/flickerfree.asp
The problem is that I don't really understand how to "override" the OnDraw method. There are no OnDraw method in the code that was generated when I created the project, and I have tried to just add the method in there but it's never called.
I'm using Visual C++ 7.0 (.net) and the ClassWizard that is mentioned on a lot of examples regarding this issue seems to be removed from the new version of Visual Studio.
I would be greatfull for some pointers on how to do this.
|
|
|
|
|
What is the project type you created ? A MDI application ? An SDI application ? A dialog project ? The OnDraw method is only there if you are handling a class based on CView . CView::OnDraw is a virtual function that you can override in order to define custom behaviour.
The concept of overriding is related to the object-oriented programming model. Consider that you have a class, call it class Alpha, for now. Class Alpha has a member function called Func1 that is declared as virtual. If you derive a class called Class Beta from Alpha, and write a function called Func1 in there, this new function will override the old Func1 from Alpha.
In the MFC world, the class thinking is at large. What OnDraw does is answer to WM_PAINT windows message.
The Visual Studio .NET doesn't boast ClassWizard anymore. It is replaced by a more functioning event list in the Properties of the class. I assume you know how to use the Class View, which shows all the classes your project contain. In this view, right-click on the class name you wish to write a message handler to, then select 'Properties'. In the properties view, look for a row of buttons in the top section. From these, find one which gives a tooltip 'Messages' or 'Events'. Click on it. A list of Windows messages you can react to is displayed. Find 'WM_PAINT', and write 'OnPaint' into the box next to it and press enter.
Now write the code to first create a CMemDC, and draw your stuff there. Then destroy the CMemDC or let it go out of scope, and it will blit the new graphic into the target device context.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
It's a dialog project. Basicly I have a bitmap image that stretches as the background when the window is resized,
and I don't want it to flicker when I resize the window. The bitmap is drawn in the OnEraseBkgnd method, I dont know if that is all that clever but...
I have moved the drawing to the OnPaint() method. Should I call Invalidate() in the OnResize() method to for an WM_ONPAINT event?
|
|
|
|
|
Hello.
I try to Open CDaoDatabase object in Windows XP (the user has the Excel
2000), and I use the "Excel 8.0" connect string. It returns the following
error "Couldn't Find Installable ISAM". BUT the same code works in Windows
2000. I tried the "Excel 9.0" and "Excel 10.0", but without success...
CDaoDatabase* p_daoDB = NULL;
p_daoDB = new CDaoDatabase;
p_daoDB->Open(_T("SCCardOS.XLS"), // file name
FALSE, // exclusive
FALSE, // read only
_T("Excel 8.0;")); // connect string
I found the post with the same problem, but without solution ;(
I need some tips for solving...
Thank you in advance.
|
|
|
|
|
Hi there,
i want to know some things regarding process in windows. how to hide a process name. i know there is a sample in codeproject. i want to know what are the steps or what is logic behind it. what is the process difference in windows 95 series and windows nt series.
and how to hide my appication icon that comes up when you press alt+tab. in that small dialog your app icon shows up if there is more then one app running. can i remove my icon from there.
reagrds
swarup
|
|
|
|
|
Hi,
how can I add a toolbar on a view, and not the mainframe ?
|
|
|
|
|
How can I export my class in "Regular DLL that statically linked MFC"?
My class does NOT inheritance from CObject.
But it use MFC class such as CString.
Also if my class inheritance from CObject, how can I do it?
Thanks
|
|
|
|
|
I have a dialog in my application that I want to be shown in the taskbar (it's not the main window). I do this by calling this in OnInitDialog:
::SetWindowLong( m_hWnd,
GWL_EXSTYLE,
GetWindowLong(m_hWnd, GWL_EXSTYLE)|WS_EX_APPWINDOW
);
This works quite well but there is one minor bug. If that dialog has a children, for example a message box, the message box doesn't get the focus when the user click on the button in the taskbar. Instead the dialog receive the focus. If the user use Alt+Tab or trying to click on the dialog, the message box gets the focus as expected. Any suggestion how to solve this?
I'm using VC6 and have tested this in NT4.
|
|
|
|
|
You need to ensure that the parent window of the message box is the dialog.
Software Zen: delete this;
|
|
|
|
|
Thanks, but I get it same result if I do this:
::MessageBox( m_hWnd, "Bla bla bla", NULL, MB_OK);
I have checked with Spy++ and the handles are set up correctly.
However, I have found a workaround. I handle the WM_SETFOCUS message in the dialog. If the dialog gets focus and the window isn't enabled, it tries to change the focus to the popup window:
LRESULT CDialog2::OnSetfocus(WPARAM wParam, LPARAM lParam)
{
if(!IsWindowEnabled())
{
HWND child = ::GetWindow(m_hWnd, GW_HWNDPREV);
if(child != NULL)
{
TRACE(_T("Has child!\n"));
::SetFocus(child);
}
}
return 0;
}
I don't like this solution sense I doesn't understand what's going on, but I guess I could live with that.
|
|
|
|
|
Hi,
i'm developing an MDI-application with mfc .net . Now i have the question how to change the Background-Color, so that Menu, Toolbar and Statusbar - even everything - has the same style.
I first thought that updating the Function AfxRegisterWndClass(...) with my own background-brush will help. But it doesn't work. Than I tried CWinApp::SetDialogBkColor() but its not available in Visual C++ 7.
Handling the WM_CTLCOLOR or WM_ERASEBKGND messages also did no effect.
Is there any way or am i hit with blindness?
Thanx
Jo
|
|
|
|
|
Hi all, to get the real printable area of a page (on a printer of course)
is it correct to do it like this?
assuming that i want to use HIMETRIC, mydc is a device context (CDC class), and it has allready been "opened" to my printer...
dc.SetMapMode(MM_HIMETRIC);
CSize pagesize;
// get the "physical" size of the page...
pagesize.cx=dc.GetDeviceCaps(PHYSICALWIDTH);
pagesize.cy=dc.GetDeviceCaps(PHYSICALHEIGHT);
// now take off the non printable area
pagesize.cx-=dc.GetDeviceCaps(PHYSICALOFFSETX);
pagesize.cy-=dc.GetDeviceCaps(PHYSICALOFFSETY);
// returned values were in device units, we need himetric
dc.DPtoHIMETRIC(&pagesize);
// pagesize now has the real printable area of the page
is this correct? is there a better way?
thanks!
|
|
|
|
|
In some, if not most cases, I have found that the PHYSICALOFFSETX and PHYSICALOFFSETY would apply to BOTH edges of the page, so you might want to do your math like this:
// now take off the non printable area
pagesize.cx-= (2 * dc.GetDeviceCaps(PHYSICALOFFSETX));
pagesize.cy-= (2 * dc.GetDeviceCaps(PHYSICALOFFSETY));
I also don't think this accounts for any of the margins the user might have set for the printing area.
You might want to also obtain the printer device context (CreateDC) and examine the DEVMODE fields:
dmYResolution - Specifies the y-resolution, in dots per inch, of the printer. If the printer initializes this member, the dmPrintQuality member specifies the x-resolution, in dots per inch, of the printer.
Or you can get the from associated with a print job and check these fields:
Size - Specifies the width and height, in thousandths of millimeters, of the form. ImageableArea - Specifies the width and height, in thousandths of millimeters, of the form.
|
|
|
|
|
hai,
I need to find the port which is precently active and set the port settings and send date to that particular port and to receive data from that port,how am i to do it?
mithila
|
|
|
|
|
What kind of ports you meen : COM, LPT, USB ?
|
|
|
|
|
Can enyone tell me where I can find C or C++ code for Nicholl-Lee- Nicholl, line clipping, alghoritm. If you know where i can find it or you have it please send it to my e-mail: taj_sam@yahoo.com.
Thanks in advance....
|
|
|
|
|
Dunno about code, but the algorithm can be found here[^].
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
does anyone know how to deselect a list ctrl item ive tried
list.SetItemState(i, 0, 0);
but this doesnt work
anyone have any idea
thanks
|
|
|
|
|
You'll need to handle LVN_ITEMCHANGING and return FALSE to allow the item to be (un)checked or (de)selected and return TRUE to disallow a change.
Here's some code that might help.
Add this to your CMyListCtrl class definition as a protected function:
// Returns TRUE if the item is checked, false if it is not or uState == 0
inline BOOL IsChecked(UINT uState) {return
(uState ? ((uState & LVIS_STATEIMAGEMASK) >> 12) - 1 : FALSE);}
Here's a sample function for handling LVN_ITEMCHANGING:
void CTestListView::OnItemchanging(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
// If old state is unchecked and new state is checked
// then item is being checked.
if ((! IsChecked(pNMListView->uOldState)) &&
(IsChecked(pNMListView->uNewState)))
MessageBox("Item is being checked");
// If old state is checked and new state is unchecked,
// item is being unchecked
else if ((IsChecked(pNMListView->uOldState)) &&
(! IsChecked(pNMListView->uNewState)))
MessageBox("Item is being unchecked");
// return FALSE (or 0) to allow change, TRUE to prevent
*pResult = 0;
}//OnItemchanging
Select: m_ListCtrl.SetItemState(iItem, LVIS_SELECTED, LVIS_SELECTED);
Deselect: m_ListCtrl.SetItemState(iItem, 0, LVIS_SELECTED);
Focused: m_ListCtrl.SetItemState(iItem, LVIS_FOCUSED, LVIS_FOCUSED);
Unfocused: m_ListCtrl.SetItemState(iItem, 0, LVIS_FOCUSED);
|
|
|
|
|
Look at your call, the 3rd param is which state bits you want to change. Since you pass 0, no bits are changed. Pass LVIS_SELECTED in that parameter to turn off that state bit.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
#include "witty-quote.h"
Pinky, are you pondering what I'm pondering?
I think so Brain, but how will we fit the hamster inside the accordion?
|
|
|
|
|