// Trigger an assertion report, returns true if the user uses ''continue'' button or
// false if they wish to terminate the process.
bool __cdecl ExceptionHandler::Assert(const char *msg,...)
{
// Draw the dialog
ExceptionDialog = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ASSERT), 0, (DLGPROC) AssertProcedure);
// Add items to the list
HWND List = GetDlgItem(ExceptionDialog, IDC_LIST);
char g_achTemp[256]; // temporary buffer
LVCOLUMN lvc;
// Initialize the LVCOLUMN structure.
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvc.fmt = LVCFMT_LEFT;
lvc.cx = 100;
lvc.pszText = g_achTemp;
lvc.iSubItem = 0;
LoadString(GetModuleHandle(0), IDS_FIRSTCOLUMN, g_achTemp, sizeof(g_achTemp));
ListView_InsertColumn(List, 0, &lvc);
// Add data column:
lvc.iSubItem = 1;
lvc.cx = 200;
LoadString(GetModuleHandle(0), IDS_DATA, g_achTemp, sizeof(g_achTemp));
ListView_InsertColumn(List, 1, &lvc);
// Add the data:
int iRow;
LVITEM lvi;
char * names[] = { "File Name\0", "Line Number\0", "Message\0" };
// Initialize LVITEM members that are common to all items.
lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
lvi.state = 0;
lvi.stateMask = 0;
lvi.iImage = 0; // image list index
// Add names:
for (iRow = 0; iRow < 3; iRow++)
{
lvi.pszText = names[iRow];
lvi.iItem = iRow;
lvi.iSubItem = 0;
lvi.lParam = (LPARAM) names[iRow]; // item data
// Add the item.
ListView_InsertItem(List, &lvi);
}
// Add File:
lvi.pszText = mfile;
lvi.iItem = 0;
lvi.iSubItem = 2;
// lvi.lParam = (LPARAM) mfile; // item data
// Add the item.
ListView_InsertItem(List, &lvi);
// db is the value that is returned by the dialog box
db = ASS_NONE;
while (1)
{
if (PeekMessage(&mag,ExceptionDialog,NULL, 0, PM_REMOVE))
{
TranslateMessage(&mag);
DispatchMessage(&mag);
}
// Check the input:
if (db == ASS_CONT)
{
// Continue:
break;
}
else if (db == ASS_STOP)
{
// Stop
break;
}
}
return true;
}
Are there freely available non-MFC classes which can handle these sorts of things? Is there a really simple way of adding the second column which I''ve missed? Should I make a window instead of a dialog box? Or is there some other, fancy, flash-band method I''ve overlooked? Any or all suggestions are more than welcomed!!!
Thanks in advance,
Simon Wilson
List Controls in Dialog Boxes [LONG]
I''m working on a debugging system at the moment, and in particular, an excaption handling window. It''s a simple dialog window hacked up in msvc, with a couple of static text windows, an icon, two buttons and a list control.
I can load, display and play with the controls. I can add the two columns to the list control, and I can add data to the first column. But I can''t seem to add anything to the second column!!!
The MSDN library doesn''t talk much about list controls in a non-MFC sense. Just when I find what I think I''m looking for, it turfs me off to the MFC section. And I don''t want to use MFC. Sure, MFC is great for office applications and stuff based upon the Win32 UI, but I don''t particularly want to go to the effort of learning MFC just to make a dialog box that users should never see! I also want to avoid additional code bloat, and the MFC debugging stuff messes up some of my debugging code.
Below is the code I''m using now. It''s current REALLY messay, but I''ve cleaned it up somewhat for this posting.
XEOS Digital Development - Supporting the independant and OpenSource game developers!
Try the following. I have not attempted to compile it so it potentially has errors, but should be pretty much correct:
should be replaced with
Anyway I believe that to get the second column it's a 1. That might be the entire problem with your first attempt, though the way I've presented is rather simpler. It's been a while but I'm pretty sure that the first column is considered column 0.
HTH.
-fel
[EDIT] Dangit, I can spell, I swear I can.![](tongue.gif)
Edited by - felisandria on March 25, 2001 7:18:15 PM
// Add names:for (iRow = 0; iRow < 3; iRow++){lvi.pszText = names[iRow];lvi.iItem = iRow; lvi.iSubItem = 0; lvi.lParam = (LPARAM) names[iRow]; // item data // Add the item. ListView_InsertItem(List, &lvi); }// Add File:lvi.pszText = mfile;lvi.iItem = 0; lvi.iSubItem = 2; // lvi.lParam = (LPARAM) mfile; // item data // Add the item. ListView_InsertItem(List, &lvi);
should be replaced with
// Add names:int index = 0;for (iRow = 0; iRow < 3; iRow++){lvi.pszText = names[iRow];lvi.iItem = iRow; lvi.iSubItem = 0; lvi.lParam = (LPARAM) names[iRow]; // item data // Add the item. index = ListView_InsertItem(List, &lvi); ListView_SetItemText( List, index, 1, mfile );}
Anyway I believe that to get the second column it's a 1. That might be the entire problem with your first attempt, though the way I've presented is rather simpler. It's been a while but I'm pretty sure that the first column is considered column 0.
HTH.
-fel
[EDIT] Dangit, I can spell, I swear I can.
![](tongue.gif)
Edited by - felisandria on March 25, 2001 7:18:15 PM
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
Thanks fel!
It''s just the kind of answer I like -- you didn''t give me everything I needed, so I had to think a bit about how I would extend the idea. My solution mightn''t be te most optimal, but it does the job. And for now at least, that''s good enough for me :-)
Keep up the good work!
Simon Wilson
It''s just the kind of answer I like -- you didn''t give me everything I needed, so I had to think a bit about how I would extend the idea. My solution mightn''t be te most optimal, but it does the job. And for now at least, that''s good enough for me :-)
Keep up the good work!
Simon Wilson
XEOS Digital Development - Supporting the independant and OpenSource game developers!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement