CComboBox list Appears After Trying to Close out Dialog
-
Hi I Decided to start a new thread because for a moment I thought I had fixed my problem of the Disappearing list with the following code I added a point to an array pointer for the strings I wanted to add
class Casidcombo : public CComboBox
{
DECLARE_DYNAMIC(Casidcombo)
private:
int cright, cbottom, ctop;public:
Casidcombo();
~Casidcombo();
char **arrayptr;
protected:virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct); virtual void DrawItem(LPDRAWITEMSTRUCT pdi); virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct); virtual void DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct); DECLARE\_MESSAGE\_MAP()
};
its the arrayptr not knowing exactly how may entries I would have I initialize it in the OnInitDialogBox of the the Hosting Dialog
m_Simple.arrayptr = new char *[j+1];
for (int i = 0; i < j + 1; i++)
m_Simple.arrayptr[i] = NULL;In the DrawItem For The Combobox I copy of over part of the string
if(arrayptr[pdi->itemID] == NULL)
arrayptr[pdi->itemID] = new char(9);
memset(arrayptr[pdi->itemID], 0x00, 9);
memcpy(arrayptr[pdi->itemID], lpszText, 8);I then write it out
dc.DrawText(
arrayptr[pdi->itemID],
8,
&pdi->rcItem,
DT_CENTER | DT_SINGLELINE | DT_VCENTER);The list now re-appears After I try closing out the Dialog by clicking on the 'X' in the right hand Corner I guess this drives the DrawItem function My question is after appearing and disappearing initially (the list) of the ComboBox the vertical scroll bar is missing as well until I clisk on the 'X' in the right hand corner after which everything re-appears I guess that most Drive DrawItem I am still Baffled Why initially it disappears along with the scroll bar This the last piece of code in the OnInitDialog
ShowWindow(SW_SHOW);
ShowWindow(SW_SHOW);return TRUE;
This is my message map I only have a Measure Item Message
BEGIN_MESSAGE_MAP(Casidcombo, CComboBox)
ON_WM_MEASUREITEM()
END_MESSAGE_MAP() -
Hi I Decided to start a new thread because for a moment I thought I had fixed my problem of the Disappearing list with the following code I added a point to an array pointer for the strings I wanted to add
class Casidcombo : public CComboBox
{
DECLARE_DYNAMIC(Casidcombo)
private:
int cright, cbottom, ctop;public:
Casidcombo();
~Casidcombo();
char **arrayptr;
protected:virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct); virtual void DrawItem(LPDRAWITEMSTRUCT pdi); virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct); virtual void DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct); DECLARE\_MESSAGE\_MAP()
};
its the arrayptr not knowing exactly how may entries I would have I initialize it in the OnInitDialogBox of the the Hosting Dialog
m_Simple.arrayptr = new char *[j+1];
for (int i = 0; i < j + 1; i++)
m_Simple.arrayptr[i] = NULL;In the DrawItem For The Combobox I copy of over part of the string
if(arrayptr[pdi->itemID] == NULL)
arrayptr[pdi->itemID] = new char(9);
memset(arrayptr[pdi->itemID], 0x00, 9);
memcpy(arrayptr[pdi->itemID], lpszText, 8);I then write it out
dc.DrawText(
arrayptr[pdi->itemID],
8,
&pdi->rcItem,
DT_CENTER | DT_SINGLELINE | DT_VCENTER);The list now re-appears After I try closing out the Dialog by clicking on the 'X' in the right hand Corner I guess this drives the DrawItem function My question is after appearing and disappearing initially (the list) of the ComboBox the vertical scroll bar is missing as well until I clisk on the 'X' in the right hand corner after which everything re-appears I guess that most Drive DrawItem I am still Baffled Why initially it disappears along with the scroll bar This the last piece of code in the OnInitDialog
ShowWindow(SW_SHOW);
ShowWindow(SW_SHOW);return TRUE;
This is my message map I only have a Measure Item Message
BEGIN_MESSAGE_MAP(Casidcombo, CComboBox)
ON_WM_MEASUREITEM()
END_MESSAGE_MAP()I have used user drawn ListView controls without problem in the past. I notice that you are using a CDC to draw the text in the view rather than responding to the notification messages and returning the relevant data. However, my sample does not use MFC so I may well be on the wrong track.
-
I have used user drawn ListView controls without problem in the past. I notice that you are using a CDC to draw the text in the view rather than responding to the notification messages and returning the relevant data. However, my sample does not use MFC so I may well be on the wrong track.
Richard there are two api in DrawItem that are not supported in Native Win32 FillSolidRect only thing close is FillRect which takes a brush Regardless I was getting a heap corruption so I ran my code in debug with the following
// InitCommonControlsEx(&InitCtrls);
#if _DEBUG
afxMemDF = allocMemDF | checkAlwaysMemDF;
#endifand at exiting DrawItem got the following
#if defined _NO_CRT_STDIO_INLINE
;
#else
{
int const _Result = __stdio_common_vsnprintf_s(
_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS,
_Buffer, _BufferCount, _MaxCount, _Format, _Locale, _ArgList);return \_Result < 0 ? -1 : \_Result;
}
#endifExiting DrawItem I am getting a heap corruption
-
Richard there are two api in DrawItem that are not supported in Native Win32 FillSolidRect only thing close is FillRect which takes a brush Regardless I was getting a heap corruption so I ran my code in debug with the following
// InitCommonControlsEx(&InitCtrls);
#if _DEBUG
afxMemDF = allocMemDF | checkAlwaysMemDF;
#endifand at exiting DrawItem got the following
#if defined _NO_CRT_STDIO_INLINE
;
#else
{
int const _Result = __stdio_common_vsnprintf_s(
_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS,
_Buffer, _BufferCount, _MaxCount, _Format, _Locale, _ArgList);return \_Result < 0 ? -1 : \_Result;
}
#endifExiting DrawItem I am getting a heap corruption
You need to actually trace the code to see where the heap is getting corrupted. It is usually caused by writing too many bytes into an allocated buffer. Notice that
__stdio_common_vsnprintf_s
takes two values which indicate the length, so one of them could be wrong. -
You need to actually trace the code to see where the heap is getting corrupted. It is usually caused by writing too many bytes into an allocated buffer. Notice that
__stdio_common_vsnprintf_s
takes two values which indicate the length, so one of them could be wrong.I Did but I don't understand why I am getting a list of Addreess Spaces information from z/os I only want to Add the the list box the Job Name. Asid information is 45 bytes the first 8 is the JobName. So the First would be *Master* I moved the code which copies the first 8 charcates from CComboBox::DrawItem to the DialogBox just got Debug Assert on the AddString I think I am doing everything right;
m_Simple.arrayptr = new char *[j+1];
traverse = instr;
for (int i = 0; i < j + 1; i++)
{
m_Simple.arrayptr[i] = new char(9);
memset(m_Simple.arrayptr[i], 0x00, 9);
memcpy(m_Simple.arrayptr[i], traverse, 8);
m_Simple.AddString(m_Simple.arrayptr[i]);
traverse = (char *)traverse + 45;
}The twisted Arrow after the Debug Heap Assertion is pointing to
traverse = (char *)traverse + 45
So I guess there is a problem with AddString Not sure what I am doing wrong
-
I Did but I don't understand why I am getting a list of Addreess Spaces information from z/os I only want to Add the the list box the Job Name. Asid information is 45 bytes the first 8 is the JobName. So the First would be *Master* I moved the code which copies the first 8 charcates from CComboBox::DrawItem to the DialogBox just got Debug Assert on the AddString I think I am doing everything right;
m_Simple.arrayptr = new char *[j+1];
traverse = instr;
for (int i = 0; i < j + 1; i++)
{
m_Simple.arrayptr[i] = new char(9);
memset(m_Simple.arrayptr[i], 0x00, 9);
memcpy(m_Simple.arrayptr[i], traverse, 8);
m_Simple.AddString(m_Simple.arrayptr[i]);
traverse = (char *)traverse + 45;
}The twisted Arrow after the Debug Heap Assertion is pointing to
traverse = (char *)traverse + 45
So I guess there is a problem with AddString Not sure what I am doing wrong