|
See here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
i'm confused, the link just takes me to the discussion board
|
|
|
|
|
You referenced an article by Eugene Polonsky. The source code is in that article.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hello,
I have a CFormView in which i have a tabcontrol with two tabs and there are two dialog boxes which act as the pages for the tabs. Inside these dialog boxes i have added a CListCtrl which i would like to populate with data. These two dialog boxes have their own classes and I have added a variable to each of these dialog boxes pointing to the CListCtrl. However when i want to use this variable inside the Dialog class to populate the CListCtrl I notice that the CListCtrl hWnd = 0x00000000. I think this is the problem and does anyone know how to fix it?
thanks,
Lino
|
|
|
|
|
Do you have an entry for the list control in the dialog's DoDataExchange() method? At what point are you trying to populate the list control?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
here it is:
the base code for this is from something published by Ben Hill on CTabCtrl applications.
//*View.h
CMyTabCtrl m_tabMyTabCtrl;
In OnInitialUpdate in my *View.cpp
void CTestTabCtrlThreeView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
m_tabMyTabCtrl.InsertItem(0, _T("Tab One"));
m_tabMyTabCtrl.InsertItem(1, _T("Tab Two"));
m_tabMyTabCtrl.Init();
}
//Init is a member function of the CMyTabCtrl Class
void CMyTabCtrl::Init(void)
{
m_tabCurrent=0;
m_tabPages[0]->Create(IDD_TAB_ONE, this);
m_tabPages[1]->Create(IDD_TAB_TWO, this);
m_tabPages[0]->ShowWindow(SW_SHOW);
m_tabPages[1]->ShowWindow(SW_HIDE);
SetRectangle();
}
void CMyTabCtrl::SetRectangle(void)
{
CRect tabRect, itemRect;
int nX, nY, nXc, nYc;
GetClientRect(&tabRect);
GetItemRect(0, &itemRect);
nX=itemRect.left;
nY=itemRect.bottom+1;
nXc=tabRect.right-itemRect.left-1;
nYc=tabRect.bottom-nY-1;
m_tabPages[0]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW);
for(int nCount=1; nCount < m_nNumberOfPages; nCount++)
{
m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW);
}
//below this point is where my code begins
//here i create a tmp object of type CTabOne which is derived from CDialog
CTabOne tmp;
tmp.Populate();
}
//CTabOne is the dialog box created to work with TabOne of the CTabCtrl
//and it has a data member of type CListCtrl m_TabOneList
void CTabOne::Populate(void)
{
CPersonInfo Person;
m_TabOneList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
//ListView_SetExtendedListViewStyle(rDest.m_hWnd, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
//get client rect of list view control
RECT rect;
m_TabOneList.GetClientRect(&rect);
//delete all of the items in teh CListCtrl
//deletes all rows in the CListCtrl before populating
m_TabOneList.DeleteAllItems();
//open CRecordSet
if(Person.IsOpen())
Person.MoveFirst();
else
Person.Open();
//test to see if there are zero columns
if(m_TabOneList.GetHeaderCtrl()->GetItemCount() == 0)
{
//insert column headings
//rDest.InsertColumn(
m_TabOneList.InsertColumn(0, "First", LVCFMT_LEFT, rect.right/2);
m_TabOneList.InsertColumn(1, "Last", LVCFMT_LEFT, rect.right/2);
}
//loop to add rows to listview control
while(Person.IsEOF() == false)
{
//add each row
int row = m_TabOneList.InsertItem(m_TabOneList.GetItemCount(),Person.m_FirstName);
//set next column item
m_TabOneList.SetItemText(row, 1, Person.m_LastName);
//assign the row to an invisible column
m_TabOneList.SetItemData(row, Person.m_ID);
//move to next row
Person.MoveNext();
}
}
void CTabOne::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1, m_TabOneList);
}
hope this helps.
Thanks for your Help.
Lino
|
|
|
|
|
lino_i wrote:
CTabOne tmp;
So is this a modal or modeless dialog? In either case, it looks as though the list control does not actually exist at the point in which you are attempting to populate it.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
that's why i am asking for help...can you help?
|
|
|
|
|
Controls on a dialog should not be messed with (e.g., populated, moved, sized, read from) before the dialog's OnInitDialog() method, or after the dialog has been dismissed.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
what does that mean...why are u being cryptic...i am coming here for answers not to have a philosophical discussion about MFC or any other language. I don't mean to be hostile but why are u being cryptic...do you have a solution if so please write it out. thanks, Lino
|
|
|
|
|
Anonymous wrote:
why are u being cryptic
Vs V jnf orvat pelcgvp, V jbhyq unir ercyvrq jvgu EBG-13!
Anonymous wrote:
i am coming here for answers not to have a philosophical discussion about MFC or any other language
There was nothing philosophical about the straightforward answer I gave you.
Anonymous wrote:
do you have a solution if so please write it out
I did everything (hint: use the OnInitDialog() method) but write the code for you. I did not think you wanted me to do all of your work!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
very funny with the cryptic notes above...good one...
you are not doing all of the work i have done most of it...and that is what a message board is for. we learn by example and as much as I and everyone try to learn on our own sometimes yes we do need to see the code and that is OKAY too!
The bottom line is that I don't know how to do it and that's it.
If you are still interested in helping.
When I added the to TabOne and TabTwo Classes which are the dialogs and derived from CDialog for the tabs where the list control is. The wizard never included the OnInitDialog() method...do you know why that is?
Lino
|
|
|
|
|
Anonymous wrote:
The bottom line is that I don't know how to do it and that's it.
Based on the code you provided, I just assumed that you knew your way around MFC.
Anonymous wrote:
The wizard never included the OnInitDialog() method...do you know why that is?
Even though ClassWizard did not add the OnInitDialog() method for you, that does not mean you cannot add it later either manually or by invoking ClassWizard again. For the former, just add to the dialog's .h and .cpp files. For the latter, select the dialog's class in the Class name: combobox, select WM_INITDIALOG in the Messages: listbox, then click the Add Function button. Now select the newly added item in the Member functions: listbox and click the Edit Code button.
Does that help?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
that helps...i still have to figure out what goes in the OnInitDialog Box.
I figured that I needed to do something in the OnInitDialog Box but when the wizard didn't provide that method i guessed it wasn't necessary...
so at the risk of being blundt...what goes in the method?
thanks.
Lino
|
|
|
|
|
lino_i wrote:
what goes in the method?
The code that populates the list control.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DavidCrow wrote:
The code that populates the list control.
David, now you are cryptic.
Well lino, In OnInitDialog you can do anything related to controls on the dialog. e.g., populating a list control (as is done here) or Creating an image list and bla bla. This is called just before OnPaint() method so it is advised to initialize your dialog controls here.
"Aerodynamically, the bumble bee shouldn't be able to fly, but the
bumble bee doesn't know it so it goes on flying anyway." - Mary Kay Ash
My Articles
|
|
|
|
|
I fail to see how your response is any "better" than mine. Given that he already has the code to populate the list control (in a method conveniently named Populate() ), it's simply a matter of moving that code to the OnInitDialog() method, or calling the method outright.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Sorry David if I hurt You. I guess he was having problems related to the sequence of calls like which is called when. So, I just tried to explain that a bit.
"Aerodynamically, the bumble bee shouldn't be able to fly, but the
bumble bee doesn't know it so it goes on flying anyway." - Mary Kay Ash
My Articles
|
|
|
|
|
Hello:
I'm looking for any type of menu subclassing without using the MFC classes, (the mayor part of the examples in the web uses it), i would like use them in an application what i'm developing, but it don't use the MFC( these classes don't likes me ), and is late like to be able the change, please if someone knows how do this, explain me
Thank you.
|
|
|
|
|
I have never done owner drawn menus myself, I don't believe they are necessary as the default menus work just fine. But the easiest way to do it is to look at the samples on this site. Sure most of them are written using MFC, but all you have to remember is that MFC is just a wrapper around the WIN32 API. Anything that can be done in MFC can be done in Win32, it's usually just harder in Win32.
So when you see CMenu::DrawItem , you have to handle the WM_DRAWITEM message, CMenu::MeasureItem , WM_MEASUREITEM , etc.
See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/menus.asp
[^] for more information on the Win32 menu functions.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
I have a database with 15 fields in it. I am using to flexgrids and filling them manually by retrieving values from the database, record by record. I have placed the twogrids in two different classes derived from CRecordview, and are hooked to the database by a CRecordset dericed class,(again manually, not using bound data controls like ADO).These two view classes have their own CMDIChild derived window classes, and I am creating two different window frames,one for each, and placing them in my application as I can best possibly adjust. THe real trick comes here. In the first grid which I call an abstract grid, I am filling it up with only 8 of the 15 database fields. In the second grid which is in a different class and window, I have just one row, and I call it the detailed grid. This one row of the grid has to be filled with the database fields (All 15) only by a single record at a time. This single record is the one which I select by just clicking on the desired row in the first grid in the other class (Abstract grid). My actual question now is "Is there a way such that when I click on a certain row in the abstract grid, I capture the row number(=first field of the database = serial no = primary key)and call the LoadGrid function for the detailed grid in the other class and pass this captured row number to precisely fill the detailed grid with only that record whose serial no is same as the row number passed, and all this has to be accomplished by just a click on a row in the abstract grid?"
long live the dEvIL
|
|
|
|
|
Hello,
I'm quite irritated by the source and the MSDN Library for CCommandLineInfo. For the documentation of ParseParam it says:
The framework calls this function to parse/interpret individual parameters from the command line. The second version is only available in Unicode projects.<br />
<br />
virtual void ParseParam(<br />
const char* pszParam,<br />
BOOL bFlag,<br />
BOOL bLast<br />
);<br />
virtual void ParseParam(<br />
const TCHAR* pszParam, <br />
BOOL bFlag,<br />
BOOL bLast<br />
);
But in the header I find the following declaration:
virtual void ParseParam(const TCHAR* pszParam, BOOL bFlag, BOOL bLast);<br />
#ifdef _UNICODE<br />
virtual void ParseParam(const char* pszParam, BOOL bFlag, BOOL bLast);<br />
#endif
It is the other way round. Using a char* in Unicode projects and TCHAR* in multibyte projects???That doesn't make sense to me because then one declaration would be enough (TCHAR is actually a char in multibyte projects). But after debugging it with Visul C++ 7.1 it seemed that the code of the MFC doesn't belong to the used MFC library, because independent on wether I build Unicode (with _UNICODE and UNICODE defined) or not the ParseParam with TCHAR is always used. Is this correct?
I ask because I want to extend CCommandLineInfo for my own parameters and I don't know which declaration of ParseParam I have to derive. I will build my app as Unicode as well as multibyte string executable.
Could someone help me in this issue.
Thanks in advance Konrad
|
|
|
|
|
The documentation has it backwards, the first one (const char* ) is only available in unicode builds. AFAIK it is provided so that unicode apps can handle an ANSI string being passed in as the commandline. You will notice that the const TCHAR* version is available in both unicode and ansi builds.
I would override the const TCHAR* version.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Thank you very much. That would be an explanation, but obviously it is not right. If you have a look at the code of CWinApp
void CWinApp::ParseCommandLine(CCommandLineInfo& rCmdInfo)<br />
{<br />
for (int i = 1; i < __argc; i++)<br />
{<br />
LPCTSTR pszParam = __targv[i];<br />
BOOL bFlag = FALSE;<br />
BOOL bLast = ((i + 1) == __argc);<br />
if (pszParam[0] == '-' || pszParam[0] == '/')<br />
{<br />
bFlag = TRUE;<br />
++pszParam;<br />
}<br />
rCmdInfo.ParseParam(pszParam, bFlag, bLast);<br />
}<br />
}
Here you can see that the parameter is wchar_t* for Unicode and char* for multibyte as parameter. So in every condition the TCHAR variant gets called! Do you have any explanation for this.
Regards
Konrad
|
|
|
|
|
WMI Blues
I am trying to set the NIC properties on a local machine using WMI. The code to do this is written in C++. I have a windows service and the code to set the NIC settings is handled in that service.
Problem:
I can get two of the properties always (does not matter which one like ip, default gateway or DNS) to set. However, on the third attempt to set any property, the connectServer () function fails (connect server function is required to get the namespace). I tried another experiment, when I restart my service after setting a property it will always work. The CoInitializeSecurity settings are exactly the same as the one in my MFC app. I am clueless at this point and I have a hunch that the code to set NIC settings residing in a service has got something to do with my program not running properly.
Note: I created a test MFC application that uses all my above functions and it works well all the time.
Any help will be appreciated
Thanks
newbee78
|
|
|
|
|