|
gayatri.neelema wrote: could you please help me
Of course yes, but read up on tab control (there are plenty of samples all over the internet) and if you encounter a trouble, come back and post what do you need help with.
It is not a very daunting task, if you ask me.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Create a group box with WS_VSCROLL style.
|
|
|
|
|
Hi,
I am working on an mfc application and implementing chat module. In chat module i need to give the function of sending emoticons. I am using a button with text emticons and when i click it i am opening a dialog box which is having several smiley.
Now the problem is that I want open the DialogBox having emoticons just above the button having text as emoticons. How can i position my DialogBox at just top of the button.
Thanks In Advance.
Dhiraj Kumar Saini
|
|
|
|
|
Make the coords of the button available to the dialog and then use SetWindowPos [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Please if u dont mind let me know how to get the coordinates of a button control.
Thanks.
|
|
|
|
|
GetWindowRect(), ScreenToClient() and things like that...
Just attempt to use the documentation. That will be the first step.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Well, in the chat window class (say CMyChat ):
(1) define a (public ) accessor for button coordinates, for instance,
CRect GetMyButtonRect();
(2) pass the this pointer to the dialog constructor, i.e.
CMyDialog myDlg(this);
Hence the dialog is able to get Button coords:
CMyChat * pParent = reinterpret_cast< CMyChat *> (GetParent());
CRect rcButton = pParent->GetMyButtonRect();
BTW: to retrieve button coords, use CButton::GetWindowRect() method.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
when debug my program, an error happens: Unhandled exception in **.exe (user32.dll) : 0xC0000005: Access Violation.
the stack information showed as follows:
USER32! 77d3e176()
USER32! 77d2927b()
USER32! 77d3a193()
USER32! 77d2c89a()
USER32! 77d306ec()
USER32! 77d18709()
USER32! 77d187eb()
USER32! 77d1c00e()
USER32! 77d1e366()
CWnd::DefWindowProcA(unsigned int 332, unsigned int 0, long 458752) line 1000 + 32 bytes
CWnd::WindowProc(unsigned int 332, unsigned int 0, long 458752) line 1586 + 26 bytes
AfxCallWndProc(CWnd * 0x0013b0a4 {CSkinComboBox hWnd=???}, HWND__ * 0x0016048e, unsigned int 332, unsigned int 0, long 458752) line 215 + 26 bytes
AfxWndProc(HWND__ * 0x0016048e, unsigned int 332, unsigned int 0, long 458752) line 368
AfxWndProcDllStatic(HWND__ * 0x0016048e, unsigned int 332, unsigned int 0, long 458752) line 57 + 21 bytes
USER32! 77d18709()
USER32! 77d187eb()
USER32! 77d1b743()
USER32! 77d1e2f7()
CComboBox::FindString(int 0, const char * 0x00070000) line 746 + 26 bytes
CDlg::Fun1() line 599 + 20 bytes
CDlg::Fun2() line 408
_AfxDispatchCmdMsg(CCmdTarget * 0x0013a4a0 {CDlg}, unsigned int 1116, int 1, void (void)* 0x00ac1541
but my codes is:
if (dwOldItemData != 0)
{
//error place, but not every time. and comboSource is a CSkinComboBox object
int nNewSel = m_comboSource.FindString(0, (LPCTSTR)dwOldItemData);
if (nNewSel != LB_ERR)
{
m_comboSource.SetCurSel(nNewSel);
return;
}
}
so, what's the problem? thk u!!!
|
|
|
|
|
What is the type of dwOldItemData (seeing the dw prefix I would guess a DWORD but that seems really strange) ? Why do you need to cast ?
|
|
|
|
|
yes,
DWORD dwOldItemData = 0;
because the codes will be run in linux OS, so i wrote a CSkinComboBox class by myself:
int FindString( int nStartAfter, DWORD dwAddData );
thk u again!!
and then, the problem is ..?
|
|
|
|
|
kaviniswell wrote: because the codes will be run in linux OS
You can't run your code on Linux: MFC is not cross-platform.
Furthermore, the FindString function accept a LPCTSTR string as second argument, so you can't 'simply' cast a DWORD to a LPCTSTR. That's why it crashes.
BTW: did you vote my previous answer down ? If yes, why ? I needed more information in order to help, what's the problem wiht that ?
|
|
|
|
|
sorry,i didnot know what it was,so i choose ...
yes, i know mfc cannot used in linuxos, so we wrote a similar combobox and other classes which we called xfc.and then we used xfc in linux/windows and other os.
thk u again!
|
|
|
|
|
Why don't you use an existing cross-platform GUI library instead of doing it all yourself. Take a look at wxWidgets[^] for instance, it will save you a lot (but really a lot) of pain...
For your problem, I don't understand why you are passing a DWORD to the function . Read the function documentation: the second argument is a string that is used for the search, so I really don't understand why you pass the DWORD. What did you have in mind, what are you trying to do ?
|
|
|
|
|
yes,wxWidgets is well good,but for us,there are some other problems, so we decided to do it ourselves.
why use DWORD? there are some other causes...
and i think this is not the key of this question now, is it?
thk u again!
|
|
|
|
|
kaviniswell wrote: and i think this is not the key of this question now, is it?
Of course it is. That's the core of your problem: you are using the FindString function in a complete erroneous way because of that. And that is the reason why it crashes. You already got a reply that could fix your problem: pass a string and not a DWORD (and try to avoid casts at all costs, because they let you do wrong things like you just did).
kaviniswell wrote: yes,wxWidgets is well good,but for us,there are some other problems, so we decided to do it ourselves.
I think it was a bad choice. Making cross-platform GUI is something extremly complex. Much more complex than trying to fix a problem you had with it. Why didn't you focus on that instead ?
|
|
|
|
|
yes, maybe u are right.
ok, the codes:
int CComboBox::FindString( int nStartAfter, DWORD dwItemData )
{
CListBox *pcListBox = GetListCtrl();
int nIndex = pcListBox->FindString( nStartAfter, dwItemData );
return nIndex;
}
int CListBox::FindString( int nStartAfter, DWORD dwItemData )
{
int nCount = GetCount();
if ( nCount <= nStartAfter )
return LB_ERR;
int nIndex;
for( nIndex=0; nIndex <= nCount; nIndex++ )
{
if ( GetItemData( nIndex ) == dwItemData )
break;
}
return ( nIndex == nCount ? LB_ERR : nIndex );
}
then what is the problem? i will be crazy now...
|
|
|
|
|
Wait a minute, I have a serious doubt: in fact you are not using MFC at all ? I thought that you were using MFC (because CComboBox is an MFC class with a FindString method).
If that is the case, I think you will have to debug a bit more in details because it will be difficult to help you without more concrete information. Use your debugger and just before the point of the crash, try to inspect all the variables to see if something is wrong or not...
|
|
|
|
|
Hi Cedric,
I still feel that he is using MFC. if not control should go to his implementation of CSkinComboBox::FindString and not the CComboBox. I tried using MFC and passing DWORD i get exactly same stack trace.
Regards,
Sandip.
|
|
|
|
|
Did you write a cross platform GUI library? Congratulations!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
not me but "us", and i just a freshman.
thk u again!
|
|
|
|
|
Well 'you' meant 'your group'.
Since in Italy we distinguish between 'tu' (i.e. 'you' as 'kaviniswell the freshman') and 'voi' , (i.e. you as 'the team wherein kaviniswell is a freshman'), I would say "Congratulations to voi!"
BTW: since your team looks very skilled, why don't you ask them too?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
|
i was confused! the skincombobox is used in winOS and actually is a mfc class ...
|
|
|
|
|
Hello I have no problem declaring a CArray variable inside a class definition but as I have a separate file that I place all my typedefs inside it have tried to define a struct that has a CArray member but compiler says:
Error 1 error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxtempl.h 272
this was my code inside TypeDefs.H
typedef struct tag_compliance_info
{
LONG lModuleCode;
LONG lModuleVersion;
CString sModuleName;
CArray<POINT> aCompliance; //Oh I forgot this board filters <> signs
} STRUCT_COMPLIANCE_INFO;
How can I solve this?
modified on Friday, October 24, 2008 3:12 AM
|
|
|
|