|
I have a requirement to fill the listbox with 2 columns.
I know how to implement a listbox with single column?
Could someone tell me how to do it?
Thanks
|
|
|
|
|
use a CListCtrl instead.
-c
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
Thanks for a quick response. I will try listcontrol.
|
|
|
|
|
I am getting an assertion failure in the last line of this function. When I click the 'Ignore' button, I am getting a message box with the message
'Unsupported operation was attempted'.
I donot have any clue to fix it?
Pl help me.
BOOL displaydlg::OnInitDialog()
{
CListCtrl *plistb = (CListCtrl *) GetDlgItem(IDC_LIST2);
LV_ITEM lvI;
// Initialize LV_ITEM members that are common to all items
lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
lvI.state = 0;
lvI.stateMask = 0;
lvI.iImage = 0;
CString str;
int i =0;
if (m_pSet1->IsOpen()) {
m_pSet1->Close();
}
m_pSet1->Open();
while (!m_pSet1->IsEOF()) {
lvI.iItem =i;
lvI.iSubItem = 0;
str = m_pSet1->m_Type;
lvI.pszText = (LPSTR)LPCTSTR(str);
lvI.cchTextMax = MAX_ITEMLEN;
lvI.lParam = (LPARAM) i;
if (plistb->InsertItem(&lvI) == -1)
AfxMessageBox(_T("ListSelectData::FillListCtrl error"), MB_OK);
i++;
m_pSet1->MoveNext();
}
return CDialog::OnInitDialog();
}
|
|
|
|
|
are there any records in the recordset?
-c
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
Yes, having 3 records.
If i comment out return CDialog::OnInitialUpdate() and return TRUE, then I am not getting this assertion failure. Only after the dailog with the listctrl filled with the records, the assertion failure appears.
|
|
|
|
|
try this:
call CDialog::OnInitDialog first in your function (not last). then return FALSE.
-c
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
|
what happens?
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
Getting an assertion failure immediately. If I click 'Ignore' button, an message box appears with msg 'unsupported operation was attempted'
|
|
|
|
|
can you step into the function?
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
I fixed the problem.
The assertion failure is thrown when calling DoDataExchange();
CDialog::OnInitialUpdate() calling CDialog::UpdateData(FALSE) calling CDialog::DoDataExchange(..).
Actually I had an button control in the dialog and an corresponding button variable in the Dialog class and hence the DoDataExchange() had an line containing button variable. Then I removed the Button variable from the resource. But didnot remove from the code.
I tried to remove the button variable from the Dialogs class and DoDataExchange() and thus it worked.
Thanks for your help. Sorry for the trouble.
|
|
|
|
|
Hello,
I would like to send a mail automaticaly from my application in vc++ with a file in attachement.
What's the good way to do it ?
Thanks in advance
DD
|
|
|
|
|
|
Hi guys.
I was wandering if it's possible to have a long text as a resource and then how to show it in a Dialog based application.
Do you have any suggestion to keep the long text inside the final ex file?
Thanks in forwarding.
Jordi
|
|
|
|
|
Put it in your application as a custom resource:
In your .rc2 file
MYTEXT TEXTFILE "Somefile.txt"
To get the text
HANDLE handle = ::LoadResource(hInstance, ::FindResource(hInstance, "MYTEXT", "TEXTFILE")) ;
char *pText = (char *)::LockResource(handle) ;
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
Hi,
I need to put together a context menu within an app that can display options that aren't known at compile time. I can create a normal pop-up menu alright I just don't know where to look to
populate the menu with items that are, for instance, defined in a user configurable file.
Any Ideas???
Josh Knox
We will rid the world of buttmunching pussnuts. Armed only with my blunt spoon of death and my circumcising potato peeler. Death and torture to them all. - Michael Martin
|
|
|
|
|
If you are using MFC, you can use CMenu methods like AppendMenu.
Following code snippet loads menu from resources and adds a separator and a dynamic menuitem:
void CMyView::OnContextMenu(CWnd* pWnd, CPoint point)
{
{
if (point.x == -1 && point.y == -1){
CRect rect;
GetClientRect(rect);
ClientToScreen(rect);
point = rect.TopLeft();
point.Offset(5, 5);
}
CMenu menu;
VERIFY(menu.LoadMenu(IDR_CONTEXT_MENU));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
pPopup->AppendMenu(MF_SEPARATOR);
pPopup->AppendMenu(MF_STRING,1111,"Dynamic");
CWnd* pWndPopupOwner = this;
while (pWndPopupOwner->GetStyle() & WS_CHILD)
pWndPopupOwner = pWndPopupOwner->GetParent();
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
pWndPopupOwner);
}
}
If you want the menu completely dynamic, then add a MF_POPUP instead of LoadMenu.
Pavel
Sonork 100.15206
|
|
|
|
|
Thanks Pavel,
That'll work great. My next question is how to map commands to the dynamically added menu items?
Josh Knox
We will rid the world of buttmunching pussnuts. Armed only with my blunt spoon of death and my circumcising potato peeler. Death and torture to them all. - Michael Martin
|
|
|
|
|
Sorry I can't help you, but I had the same problem.
I dynamically create a menu that contain a certain number of IP adresses, like :
_TRAYMENU_
192.168.0.1
62.43.12.10
etc...
and I want to copy the IP to the clipboard when I click on it (I know for the clipborad, but I don't know how to map commands...)
Thanks!
|
|
|
|
|
Look up the DYNAMENU sample in MSDN. It details how to do this stuff.
Josh Knox
We will rid the world of buttmunching pussnuts. Armed only with my blunt spoon of death and my circumcising potato peeler. Death and torture to them all. - Michael Martin
|
|
|
|
|
Add an ON_COMMAND or ON_COMMAND_RANGE macros to the message map section of the class where you want to catch them:
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
ON_WM_CREATE()
ON_COMMAND(ID_VIEW_DLLTEST, OnViewDlltest)
... and other macros added by class wizard
ON_COMMAND(ID_xxxx, OnXxxx)
END_MESSAGE_MAP()
You also need to add the void OnXxxx() method to your class.
Pavel
Sonork 100.15206
|
|
|
|
|
Hello everybody:
I want a function to be exectured when I press CTRL + Click over a bitmap image in a Dialog. I know how to do that when I to a Ctrl + Click over the Dialog itself using the OnLButtonDown() function. What do I need to do to make it happen by just clicking the bitmap image? Any answer is more than welcome.
Regards,
Luis E. Cuadrado
)
|
|
|
|
|
Place the bitmap in a static text control on your dialog. Give the control a unique ID and set the notify style for it. You can then write a handler for BN_CLICKED for the static control and check to see whether the control key is pressed (GetKeyState(VK_LCONTROL) || GetKeyState(VK_RCONTROL))
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
Hello:
I tried what you told me and this is what I put in my code:
void CMyClass::OnPicClicked() <br />
{<br />
<br />
if ((GetKeyState(VK_LCONTROL) || GetKeyState(VK_RCONTROL)))<br />
{<br />
}<br />
}
Does that looks correct? I run my application and it doesn't work.
Thank you for your reply.
Regards,
Luis E. Cuadrado
)
|
|
|
|