|
sepehr_vision wrote: // style |= CS_PARENTDC;
// style &= ~(CS_VREDRAW|CS_HREDRAW);
// SetClassLong(m_hWnd, GCL_STYLE, style);
CWnd::Create(/*"ABC"*/0,"ECMLMItem",WS_BORDER|WS_VISIBLE|WS_CLIPCHILDREN|WS_CHILD,rect,this,LISTITEM+counter,0);
try modifying it like this
CString csClassName = AfxRegisterWndClass( CS_OWNDC | CS_DBLCLKS | CS_SAVEBITS, LoadCursor( 0, IDC_ARROW ));
CWnd::Create( csClassName ,"ECMLMItem",WS_BORDER|WS_VISIBLE|WS_CLIPCHILDREN|WS_CHILD,rect,this,LISTITEM+counter,0);
nave
|
|
|
|
|
dear nave,thanks a lot for your help.
but unfortunately it doesn't work yet.
i tried it,but still when the objects are children of item,it doesn't work.
but when they are children of list,they are visible and can get and send messages.
i am hung!what should i do!
|
|
|
|
|
sepehr_vision wrote: ,but still when the objects are children of item,it doesn't work.
but when they are children of list,
I dont understand what u mean.
What about the the new window created? Is it visible?
nave
|
|
|
|
|
|
hi.
thanks for caring.
i did put the code yesterday.
but they said remove the code!
that is also available from yesterday.
void ECMLMItem::Create(int i,CWnd *pParent,CRect rect,CRect RcList)
{
/*WNDCLASS wndcls;
memset(&wndcls, 0, sizeof(WNDCLASS));
wndcls.style = 0;
wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wndcls.lpszClassName = "ABC";
DWORD style = GetClassLong(m_hWnd, GCL_STYLE);
RegisterClass(&wndcls);*/
// style |= CS_PARENTDC;
// style &= ~(CS_VREDRAW|CS_HREDRAW);
// SetClassLong(m_hWnd, GCL_STYLE, style);
CWnd::Create(/*"ABC"*/0,"ECMLMItem",WS_BORDER|WS_VISIBLE|WS_CLIPCHILDREN|WS_CHILD,rect,this,LISTITEM+counter,0);
counter++;
obj[i] = new ECMLMObjects();
obj[i]->create(i,pParent,rect,RcList);
}
void ECMLMItem::CreateItem(CWnd *pParent,int i)
{
if(i<10)
{
rect.left=RcList.left+12;
rect.top=RcList.top+20*i+1;
rect.right=RcList.right-12;
rect.bottom=rect.top+20;
ECMLMItem::Create(i,pParent,rect,RcList);//create a new item as a rectangle to put 3 objects in it
}
}
//
void ECMLMObjects::create(int i,CWnd *pParent,CRect rect,CRect RcList)
{
int w;
w=RcList.Width()-20;
rect.left=RcList.left+12;
rect.top=RcList.top+20*i+5;
rect.right=rect.left+w*3/15-2;
rect.bottom=rect.top+20;
btn[i].Create(""/*text*/,WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,rect,pParent,Button+i);
rect.left=RcList.left+w*3/15+15;
rect.top=RcList.top+20*i+5;
rect.right=rect.left+w*4/15-4;
rect.bottom=rect.top+20;
edt[i].Create(WS_VISIBLE|WS_CHILD,rect,pParent,editbox+i);
rect.left=RcList.left+w*7/15+15;
rect.top=RcList.top+20*i+5;
rect.right=RcList.right-12;
rect.bottom=rect.top+20;
name[i].Create("Hello"/*name*/,WS_VISIBLE|WS_CHILD,rect,pParent,statictext+i);
}
|
|
|
|
|
I'm generating excel report from MFC. whenever the cell contains data like A1-1 i.e. A/a and some no and the - it gets converted to arabic characters. I found one solution which says about some registery entry. I want to solve the problem programmatically from MFC.
I used worksheet->Cells->NumberFormat = "General"
But if the registery entry is set for that format then it doesn't work.
How can do it through code?
Please mail me if anybody has the solution.
My email id is pankajachavan@gmail.com
Thanks
|
|
|
|
|
Hi all,
Is there any problem in ownerdraw list control having LVS_EX_CHECKBOXES style?
It does not respond to mouse click in the checkbox. But can check/uncheck by pressing spacebar.
Thank you.
- NS -
|
|
|
|
|
|
Sorry. It is not connected with owner draw. It uses custom draw.
- NS -
|
|
|
|
|
I'm attempting to write a program that can store and display a sparse table that shows students and their courses. I'd also like it to show the data values of the next student or course in each list. The table would display course columns and student rows. My goal is to be able to eliminate the arrays I currently have in order to get my program to run faster with a massive amount of data. However, I can't seem to find any useful information on sparse tables using linked lists anywhere. Can anyone help? I'm totally lost.
|
|
|
|
|
nyteryder79 wrote: sparse tables using linked lists
A std::map might also be used for a sparse array or sparse matrix.Other container classes can also be used like vector, list etc depending on your need.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi,
I have created a propertysheet with two property pages.
In the first property page i displayed 'employee names ' from the database and displayed in the grid lines.
I select on name and activate another property page.Using querysiblings i got the name in the second property page.
And using that ,employeename' i write a query to get the data from the database and displayed in the controls.
First time it is running fine.
Second time if i select another emplyoee name I am getting the correct results from database but the old data is displayed in the controls.
BOOL CCampaignDataEntryDlg::OnInitDialog()
{
CPropertyPage::OnInitDialog();
setUpODBC();// establish database connection
long x=QuerySiblings(1,(long)&m_querySibling);
CString* pString=(CString*)x;
pStr=*pString;
AfxMessageBox(pStr); //display employee name say 'tejaswini'
SQLRETURN sr;
SQLHSTMT hstmt;
CString campid;
campid.Format("SELECT empName,empID FROM EMPLOYEEDETAILS WHERE EMPNAME= '%s'",pStr);
SQLCHAR* SQL = (SQLCHAR*)(LPCSTR)campid;
I read the empName into roow.EmpName;
and empID into roow.EmpID;
CEdit *Name;
Name= reinterpret_cast<cedit *="">(GetDlgItem(IDC_EMPNAME));
Name->SetWindowText(roow.EmpName);
CEdit *EmpId;
EmpId= reinterpret_cast<cedit *="">(GetDlgItem(IDC_EMPID));
EmpId->SetWindowText(roow.EmpID);
}
BOOL CCampaignDataEntryDlg::OnSetActive()
{
if(m_Status!="") //m_Status is to used to know whether the
//property page is activated or not
OnInitDialog();
/*One of our friends told not to call OnInitDialog()here and he suggested to write the code here instead writing in OnInitDialog().I did like that and in the first control that is Edit box is not displaying the text. Other controls are displaying it.*/
return CPropertyPage::OnSetActive();
}
BOOL CCampaignDataEntryDlg::OnKillActive()
{
m_Status="abc";
return CPropertyPage::OnKillActive();
}
Can u plz say How can I solve this problem?
Thanks in advance.
|
|
|
|
|
Is there any message that gets posted on event of a button press?
The ON_BN_CLICKED is used for specific buttons and that message gets sent if the specific button is pressed. If I have a dialog with 10 buttons, and I want to know if a button got pressed (any button, it doesn't matter which), how do I do this?
Thanks,
skyapie
|
|
|
|
|
Derive a class say ButtonEx from CButton and over ride DrawItem( LPDRAWITEMSTRUCT lpDIS )
Create buttons as the object of ButtonEx
ButtonEx::DrawItem( LPDRAWITEMSTRUCT lpDIS )
{
if(( lpDIS->itemState & ODS_SELECTED ))
{
// means buton is clicked
}
}
|
|
|
|
|
This is a very strange way of going about things. The code in question will fire every time a clicked button is rendered and not just once when it's clicked.
Steve
|
|
|
|
|
Thank you for pointing out
I was only thinking about getting the selection status. My solution was poor.
|
|
|
|
|
I like to autosize the owner draw button depending upon the text that it load dynamically based on localization strings. so some strings are large than others. Keeping this I override DrawItem in the inherited class from CButton.
The sample code is below
void CMyGraphicButton::DrawItem (LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CString cs;
CString cslong;
ASSERT(lpDrawItemStruct->CtlType == ODT_BUTTON);
LPCTSTR lpszText = (LPCTSTR) lpDrawItemStruct->itemData;
if (!lpszText || lpszText == (LPCTSTR)-1)
{
GetWindowText (cs);
}
else
cs = lpszText;
// now i m trying to resize , so let try to increase the size of button unconditioally
// I get
//lpDrawItemStruct>rcItem.left =0
//lpDrawItemStruct>rcItem.right =75
//lpDrawItemStruct>rcItem.top = 0
//lpDrawItemStruct>rcItem.bottom = 25
//As my button is on extreme right side of dialog so i tried to extend/increase the size of
// button of the left side as follows
lpDrawItemStruct>rcItem.left -= 25 ;
// but the above causes the text to be moved on right side insead of resize/increase the
//button size.
Any idea or help is appriciated.
Thanks
Anil
}
[AKS]
|
|
|
|
|
u will receive a WM_COMMAND message(OnCommand) when any button is pressed. Also check the HIWORD of the wParam is BN_CLICKED to ensure that the message has arrived due to a button click.
nave
|
|
|
|
|
Handle the BN_CLICK notification in the parent window. This notification is packaged as a WM_COMMAND message.
Steve
|
|
|
|
|
Thanks! It worked
|
|
|
|
|
Hi again,
thanks for the reply last time....
Do you know how to do the same thing for the events where the user moves a scroll bar or clicks in a list box/list control?
I couldn't get it to work using the OnCommand method, so I used OnNotify. See code here...
BOOL CBaseFormView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) <br />
{<br />
NMHDR* pNMHDR = (NMHDR*)lParam;<br />
<br />
<br />
if(pNMHDR->code == 0xFFFFFFF4) <br />
{<br />
AsyncServicesUpdateInactivityTimer(this->m_hWnd);<br />
}<br />
<br />
return CFormView::OnNotify(wParam, lParam, pResult);<br />
}
Except I'm not sure what the notification codes for selecting something within a list box or list control, or moving the scrollbar are.
Thanks again
Skyapie
|
|
|
|
|
The WM_HSCROLL and WM_VSCROLL messages are sent when scrolling occurs in a Window's standard scroll bar. When the user clicks in a control it depends on the control. For example List View controls send the NM_CLICK notification.
Steve
|
|
|
|
|
|
when a button is clicked, the parent of the button will receive WM_COMMAND message. Check whether the high-order word of the wparam is BN_CLICKED.
if( message == WM_COMMAND && BN_CLICKED == HIWORD( wParam))
{
// button is clicked.
}
the lparam will be having the handle of button.
nave
|
|
|
|
|
but i want my button handle click, only use itself message.
LRESULT ButtonProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
........
}
return DefWindowProc(message, wParam, lParam);
}
|
|
|
|