|
I am having a very frustrating problem, and i'm hoping someone might have some experience with CListCtrl.
Basicly I have a list, and when someone changes their selection i call a function which traces information about the item selected.. this is the code that vc++ .net generated for me, and the 'UpdateButtonStates()' is my function..
// this function is called whenever the user changes the selection on the listctrl
void CCompanyMaint::OnLvnItemchangedComplist(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<lpnmlistview>(pNMHDR);
UpdateButtonStates(); // change the availability of the buttons based on who is selected
*pResult = 0;
}
so, this calls my function:
void CCompanyMaint::UpdateButtonStates(void)
{
if (m_lstCompanies.GetSelectionMark() != -1)
{
CString strTemp;
int nPos = m_lstCompanies.GetSelectionMark();
int nVal = m_lstCompanies.GetItemData(m_lstCompanies.GetSelectionMark());
strTemp.Format("Position = %i, nVal = %i, name = %s\n", nPos, nVal, m_lstCompanies.GetItemText( m_lstCompanies.GetSelectionMark(), 0));
TRACE(strTemp);
}
}
the problem is that the data which it gets is always the previously selected item, not the currently selected item.. in other words if i choose item 5, then item 1, then it displays item 5's info, when i select a different item then it shows the data for item 1.. its lagged behind one move.. it always shows the data from the item that just got unselected, not the one im currently selecting.. ive tried moving the UpdateButtonStates() function in the OnLvnItemchangedComplist to above and below and in between the generated code.. but it doesn't matter.. any suggestions?
-dz
|
|
|
|
|
Try to use UpdateButtonStates()as a couple. It means your code is:
void CCompanyMaint::OnLvnItemchangedComplist(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast(pNMHDR);
UpdateButtonStates(); // change the availability of the buttons based on who is selected
UpdateButtonStates();
*pResult = 0;
}
I met a problem like that when I want to update user's action on my combobox, and I tried the solution above.
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
nope, just gives the bad output 2 times instead of once.. thanks for the suggestion tho
-dz
|
|
|
|
|
is there any chance that my getselectionmark() command is happening before the item actually gets selected somehow? i mean i have buttons for editing and deleting an item, and they always select the correct item in the list to edit or delete.. its just the function thats actually gets called when they change their selection that doesn't work.. ??
-dz
|
|
|
|
|
I've often had problems with monitoring list control selection changes. As a workaround, I used a timer to monitor the current selection every 200mSec. If it changed, I posted a custom message to respond to the new selection. Yes, I know this is a hack but I didn't have much of a choice.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Unfortunately im not very versed in timers, or throwing messages.. i suppose i could use some sort of time are call call the function directly as well?
the whole purpose was to enable/disable buttons based on the choice from the list.. i guess i could just give an error if they try to use the buttons..
-dz
|
|
|
|
|
I need to create an edit box that is split in two and its size and shape can be resized by the user.
|
|
|
|
|
I think your request made editbox like a grid. So you can use grid instead of.
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
I got the problem, that the combobox can be edited by the user. but i just want him to choose from my values in the list.
the option of "pulldown listfield" isn't of. cause i have to tell the combobox which value it should have, everytime the dialog comes up.
knows somebody any solution?
thanks for help.
Tom
|
|
|
|
|
You need to set the combo style to DROPLIST. You can do that through the resource editor.
Michael
|
|
|
|
|
As michael says, set the drop list style.
What you actually want your control to be is a drop down list.
A combo box is something slightly different. it's a COMBination of a listBOX and an edit control.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
-If you use MFC toolbox to create it, change style it to
Drop List in Styles tab.
-If you use code, use style: CBS_DROPDOWNLIST
Try it !
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
Has anybody successfully used the function LogonUser(..) ?
I can't do it because i allways get the error message: ERROR_PRIVILEGE_NOT_HELD
which means that the calling process hasn't the SE_TCB_NAME privilege. How do i get that privilege ??
|
|
|
|
|
struct Inst
{ char Iname[20];
char Office[10];
float salary;
int InstId;
char phone[10];
}
void main()
{ Inst ISInst1;
Inst* InstPtr;
.
.
}
How much space will the ISInst1 variable take up in main memory. How much space will InstPtr take? Can you explain this to me?
Loli10
|
|
|
|
|
This question does not have a single answere since it depends on the target machine, your compiler, compiler settings...
If you run on Win32 and use VC compiler with standard settings I'd say your struct will take up 52 bytes of memory. There are 4 'hidden' bytes in there. two comes after Office, and 2 after phone. This is due to byte alignment. For efficiency, datatypes like float and int are put an a 4 byte boundary. This allows the CPU to fetch your data in a single call.
If you want to check the size of your datatypes you should use the operator sizeof(), e.g. int instsize = sizeof(struct Inst). This will also show that your pointer is 4 bytes (again depending on the target machine)
If you are familiar with pragmas you could try putting #pragma pack(1) before you declare your struct and se what happens.
Hope that helps.
|
|
|
|
|
Good single answer
Regards,
Alvaro
Always do right. This will gratify some people, and astonish the rest. - Mark Twain
|
|
|
|
|
The easiest way to find out would be to use the sizeof operator:
int viSize1 = sizeof(ISInst1);
int viSize2 = sizeof(InstPtr);
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
would anyone have an example how to get a drives freespace
i know the call but...
thanks
shotgun
|
|
|
|
|
<br />
DWORD dwsectorsPerCluster,<br />
dwBytesPerSector,<br />
dwNumFreeClusters,<br />
dwNumTotalClusters;<br />
if (GetDiskFreeSpace("C:",
dwsectorsPerCluster,
dwBytesPerSector,
dwNumFreeClusters,
dwNumTotalClusters))
{<br />
DWORD dwFreeSpaceInBytes =<br />
dwNumFreeClusters * dwsectorsPerCluster * dwBytesPerSector;<br />
}<br />
|
|
|
|
|
...or you could use the GetDiskFreeSpaceEx(...) which will give you the free space in bytes directly.
|
|
|
|
|
Hi !
I have several databases (in mdb format) for my MFC project. I decided to put them on a server in the network. The path is like this:
//netbackup/multimedia/erginasil.mdb
The problem is: The server (netbackup)has a password which I have but the users will not have.If I first connect there ,the program runs normally. How can I acces a password protected server in the code. I found in msdn opening a password-protected "file" but I must give the "server password" to connect normally.
Thanks in advence..
|
|
|
|
|
Can you not just share the folder and give the users permissions to access that one folder?
Michael
|
|
|
|
|
No I don't have the right to give permission. I am not the admin of the system. In fact I am building this program for him. And I don't want to tell him "you must give permissions to the other users for this program". Just becaouse this I have to try.
|
|
|
|
|
No I don't have the right for that. I am not the admin. In fact I am developing this program for him and I don't want to say "you must give access to other users for my program".So I have to find.
|
|
|
|
|
How can I implement word wrapping in regular edit controls w/o resorting to subclassing as much as possible.
|
|
|
|