|
If you do a web search you may find something. Here is just one of several:
http://www.sdisw.com/index.asp
|
|
|
|
|
I hope I can explain this without too much confusion.
Let's say you have an edit box in a wizard. You enter data outside the valid range. If you click Enter instead of Tab, you get an error message. If you click on Enter to dismiss the error, it acts like an Enter and goes onto the Next screen. The original code looked like this:
// Check the validity of the value
l_lVal = atof((_bstr_t)InBurstLengthStr);
if((l_lVal > m_dMaxBurstLength) || (l_lVal < m_dMinBurstLength))
{
// If the entered value is out of range then throw an error
::MessageBox(m_hWnd,
L"The Burst Length Entered is not Within the Specified Range!",
L"Data Entry Error",MB_OK | MB_ICONEXCLAMATION);
BurstLengthEdit.SetFocus();
return 0;
}
I changed it so that I got the click. I checked if the click was IDOK, called the setfocus, but that didn't help. I saw where someone else made the enter key act like a tab key if they were in an edit field with a hook. I couldn't get that to work. It just wanted to act like a Next, which was weird because it didn't appear to be the default button. Please HELP me if you can!
Thanks,
Lilian
|
|
|
|
|
The code you've posted is located in some event handler; you didn't include the function header. Which event is it?
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
The method name is OnKillFocusBurstLengthEdit, EN_SETFOCUS.
|
|
|
|
|
EN_KILLFOCUS handler doesn't give you any control over page navigation. I *guess* (never did that personally) you should check values in OnWizardNext and return -1 if they don't satisfy your conditions.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Thanks, I knew this was something beyond my control/comprehension!
|
|
|
|
|
The CFormView in my MDI project fits neatly inside my window without scrollbars appearing. I set it up so it's maximised on execution. However, on a smaller screen computer, scrollbars appear.
My question is: Is there a way to automatically resize the controls and form so that I "see" the same window no matter which computer i run it on?
Thanks
Kash
|
|
|
|
|
|
Hi,
How do I determine if the client area of my window
has been totally covered up by other windows?
In my OpenGl program, I still want to render when
the user switches away to another program, but not
when the rendering/client area is not visible.
Thanks!
Shawn
|
|
|
|
|
I guess you could fire WM_PAINT with InvalidateRect/UpdateWindow and check the rectangle returned by GetClipBox.
Or - you could sample coords in client area with WindowFromPoint
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
You might want to have a look at KB article Q75236.
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q75236
I have to admit to never having used OpenGL. Do you not do your rendering in response to WM_PAINT messages? 'Cause if your rendering is in response to WM_PAINT, you won't get any WM_PAINT messages if the window is totally obscured.
|
|
|
|
|
Many thanks.
Sincerely,Pole.
|
|
|
|
|
It seems to work, but crashes when I exit with Ok or the system menu.
The UI comes up just fine! If I comment out AddItem1, it exits fine:
BOOL CSortListCtrlTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
(void)m_ctlList.SetExtendedStyle( LVS_EX_FULLROWSELECT );
m_ctlList.SetHeadings( _T("Name,120;Date of Birth,90;Score,50;Score,200") );
CStringArray pArray;
int iArraySize = 4;
pArray.Add("ccc");
pArray.Add ("ppp");
m_ctlList.AddItem1(pArray, iArraySize , 0);
return TRUE;
}
and
int CSortListCtrl::AddItem1( CStringArray &pArray, int iArraySize , int nPos)
{
int nIndex = InsertItem(LVIF_TEXT|LVIF_STATE, 0, "abc",0,LVIS_SELECTED,0,0);
ASSERT(nIndex != -1);
if (nIndex < 0) return(nIndex);
return(nIndex);
}
I dont use any of the info I passed in (for testing). I dont do anything fancy. This is the barest code with which it crashes in OnDestroy
which has only CDialogs destroy in it. If I comment out the InsertItem it exits fine. if I use instead
int nIndex = InsertItem( 0, "abv");
, it still crashes
What shall I look at here that might be the problem?
Appreciate your help,
ns
|
|
|
|
|
What crashes - are you getting an ASSERT or GPF? Look at the call stack at the crash point and check where exactly problem is located.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
memory cant be read.
(I hope theres enough info here for you to advise me...)
call stack points to:
void CSortListCtrl::FreeItemMemory( const int iItem )
{
ItemData* pid = reinterpret_cast<ItemData*>( CListCtrl::GetItemData( iItem ) );
LPTSTR* arrpsz = pid->arrpsz;
for( int i = 0; i < m_iNumColumns; i++ )
delete[] arrpsz[ i ];
delete[] arrpsz;
delete pid;
VERIFY( CListCtrl::SetItemData( iItem, NULL ) );
}
which is from their AddItem (I want to make my own)
int CSortListCtrl::AddItem( LPCTSTR pszText, ... )
{
const int iIndex = InsertItem( GetItemCount(), pszText );
LPTSTR* arrpsz = new LPTSTR[ m_iNumColumns ];
arrpsz[ 0 ] = new TCHAR[ lstrlen( pszText ) + 1 ];
(void)lstrcpy( arrpsz[ 0 ], pszText );
va_list list;
va_start( list, pszText );
for( int iColumn = 1; iColumn < m_iNumColumns; iColumn++ )
{
pszText = va_arg( list, LPCTSTR );
ASSERT_VALID_STRING( pszText );
VERIFY( CListCtrl::SetItem( iIndex, iColumn, LVIF_TEXT, pszText, 0, 0, 0, 0 ) );
arrpsz[ iColumn ] = new TCHAR[ lstrlen( pszText ) + 1 ];
(void)lstrcpy( arrpsz[ iColumn ], pszText );
}
va_end( list );
VERIFY( SetTextArray( iIndex, arrpsz ) );
return iIndex;
}
Do I need this arrpsz stuff? Can I get rid of their freememory function? Its used by them in:
BOOL CSortListCtrl::DeleteItem( int iItem )
{
FreeItemMemory( iItem );
return CListCtrl::DeleteItem( iItem );
}
::DeleteAllItems();
}
I wont be needing to delete any items so I am paring down their class.
Appreciate your help,
ns
|
|
|
|
|
OoPs! Also used in:
void CSortListCtrl::OnDestroy()
{
for( int iItem = 0; iItem < GetItemCount(); iItem ++ )
FreeItemMemory( iItem );
CListCtrl::OnDestroy();
}
Appreciate your help,
ns
|
|
|
|
|
I have no idea how exactly CSortListCtrl works. Did you create this class yourself or downloaded from the net?
When program crashes, check the 'pid' and 'arrpsz'. Probably one of them is NULL.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
THe article and demo are from CP
http://www.codeproject.com/listctrl/sortlistctrl.asp
. I didnt call their AddItem (earlier post)where the arrpsz stuff is getting set or used - I used my little AddItem1
which does nothing except inserItem in the first column. So I'm sure the variables you mentioned are null.
Looks like I cant replace their AddItem, since I have no clue what this pid stuff is, therefore cant use it in my AddItem1.
So my challenge is to (try to) extend their AddItem so it can take in an array also, which is what I'll use to insert my items. I can ignore the arguments they pass in, and leave all the arrpsz stuff intact so it doesnt get unhappy. Thanks for pointing me in the right direction. THe call stack is useful! Never used it before...
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
I have no clue what this pid stuff is
The 'pid' variable in function causing the crash is item data. Each row in listview can have associated 32-bit value - you use GetItemData/SetItemData for that. CSortListCtrl apparently stores the pointer to some array (probably in the call to SetTextArray). pid is just the retrieved pointer. If you don't call original AddItem, then pid will be NULL and your app will die.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Hmmm.Okay. Thank you for that info.
Their addItem has one 'fixed' input variable, and unlimited optionals. I will have my subItem texts in an array and wanted to pass in an array but modifying their code is beyond my present capabiities. So I have to figure out how best to pass in my array the way they want it:
AddItem(pArray[0], pArray[1], pArray[2].......pArray[n])
which is how they want it. Its not at all obvious to me how I can loop on an index when passing in the array in this fashion.
My problem is that for one database where I get my subitem texts from, there is a particular 'n' value, and a different 'n' for a different database.So I cant hard code the AddItem parameter list. And I cant loop on an index in the argument list....
thanks,
ns
|
|
|
|
|
Their version of AddItem uses variable argument list and va_xxx stuff because they must provide convenient syntax for list controls containing different # of columns. Read the docs on va_start, va_end and va_arg and you'll get the idea what's going on. Passing array instead of array elements should be trivial.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Trying. I cant strip out their pid and arrpsz stuff safely, and its tied in with their variable optionals. Heres my attempt:
int CSortListCtrl::AddItem2( CString pArray[], int ArraySize)
{
const int iIndex = InsertItem( GetItemCount(), pArray1[0] );
LPTSTR* arrpsz = new LPTSTR[ ArraySize ];
arrpsz[ 0 ] = new TCHAR[ lstrlen( pArray1[0] ) + 1 ];
(void)lstrcpy( arrpsz[ 0 ], pArray1[0] );
for( int iColumn = 1; iColumn < ArraySize; iColumn++ )
{
CListCtrl::SetItemText( iIndex, iColumn, pArray1[iColumn] );
arrpsz[ iColumn ] = new TCHAR[ lstrlen( pArray1[iColumn] ) + 1 ];
(void)lstrcpy( arrpsz[ iColumn ], pArray1[iColumn] );
}
VERIFY( SetTextArray( iIndex, arrpsz ) );
return iIndex;
}
Appreciate your help,
ns
|
|
|
|
|
You don't need to strip anything; just change the way arguments are passed. Your code looks OK; I'd use CStringArray instead of CString[].
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
I cant thank you enough. This exchange was very instructive. I used CStringArray like you said and it works, plus no crashes!
This is a little sample I tried before I use this class in my main project, but I wanted to tailor it so I could use it -
my pArray is going to come from reading in the all values of one row of a database into a CStringArray.
Now the next thing I have to do is figure out how to get all the values of a particular column out of the listcontrol. - ah GetItemText()
I thank you very much for all the help you have been giving me , and the patience
Appreciate your help,
ns
|
|
|
|
|
Hurrah for CStringArray ! (And thanks to Tomasz! )
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|