|
thanx 4 the piece of info.but i happened to see that info earlier.i seem to have a serious problem in inderstanding the COleSafeArray .can u plz explain why we create an array DWORD numElements[] = {10, 10}; .is that a one dimensional array or something else.im totalled.plz mail me at
rajeshvv007@yahoo.com if u aint mind.
thanx 4 helpin.....
|
|
|
|
|
Taking the first example, COleSafeArray is the chart data and simplyfing it's:
<br />
COleSafeArray saRet;<br />
SAFEARRAYBOUND sab[2];
<br />
sab[0].cElements = NUM_DISCS;
sab[1].cElements = m_iCols;
sab[0].lLbound = sab[1].lLbound = 1;
<br />
saRet.Create(VT_BSTR, 2, sab);
m_msChart.SetChartData(saRet.Detach());
I hope it helps,
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
Hello,
I would like to add a new member-function to all the controls of different kind in my dialog, e.g. CEdit, CButton and so on.
Since they are all derived from CWnd I would like to know if there is a possibility to insert a new class "CWndEx" between CWnd and the control class, so that e.g. CEdit is not longer derived directly from CWnd but from CWndEx. This way I could add a new member function to CWndEx so all the my controls would inherit this function?
Seems to be a newbie question, yes?
Thank you very much...
|
|
|
|
|
i thought of extending this in CEdit Class.. so not a newbie.. he he..;P
|
|
|
|
|
No, this is not directly possible in the C++ language. I've wanted to do this myself on occasion along with making some necessary functions virtual that for some inexplicable reason are not.
But there are ways around it to get the job done. Depending on what you'd like to achieve the simplest thing you can do is just to use a global function that takes a CWnd as a parameter. You won't be able to access protected members, but for most cases this generic function should be able to achieve what you want. It's not as pretty certainly, but the most important thing is to get the program to work.
Another approach (at least for objects you directly create) would be to multiply inherit. This wouldn't apply to objects that are dynamically created, however.
|
|
|
|
|
Bill Buklis wrote:
Another approach (at least for objects you directly create) would be to multiply inherit. This wouldn't apply to objects that are dynamically created, however.
Actually I was trying to get this work for three days, I derived classes from CEdit and CButton and both from my own class "CInputCtrl" too, like this:
class CEditEx : public CEdit, public CInputCtrl
{
public:
void MyFunc();
}
class CInputCtrl
{
public:
void MyFunc();
}
But now, when running this code
CInputCtrl* pCtrl = (CInputCtrl*)GetFocus();
pCtrl->MyFunc();
the CInputCtrl::MyFunc() is called. If only I was able to "virtualize" the MyFunc() of CEditEx everything was OK.
Can I change something so it works the way I expect? I already read about multiple inheritance but could not find something helping me further on...
Thank you very much again...
|
|
|
|
|
With the code listed, you created two completely separate functions:
CEditEx::MyFunc and CInputCtrl::MyFunc. If you have a pointer to a CInputCtrl, it will call CInputCtrl::MyFunc.
To use multiple inheritance, what you want is for the code on the 2nd derivation to be more generic and not window oriented. Ths second branch should not be derived from CWnd, CObject, etc.
Sort of like this:
class CGeneric
{
virtual bool DoSomething();
}
class CMyEdit : public CEdit, CGeneric
{
bool DoSomething();
};
The CGeneric class won't have direct access to any windowing features. It's similar to using the global functions, but with more inheritance control.
|
|
|
|
|
This has always been one of those areas I get completely confused in - maybe somebody can set me straight...
I use a lot of "overlay" modeless dialogs on other dialogs (add extra functions, etc.), and I can get them to work fine, until the screen resolution is changed, then they don't match. I've tried lots of combos of ClientToScreen, etc., but no luck so far - heres the code I generally use:
// Modeless dialog #1 (which is itself an overlay on main dialog).
CRect rc;
GetWindowRect(&rc);
ClientToScreen(&rc);
// m_EQS is the overlay on the overlay.
m_EQS->SetWindowPos(&wndTop, rc.left+355, rc.top-5, 0, 0, SWP_NOSIZE);
m_EQS->ShowWindow(TRUE);
This works fine, until the screen resolution changes, then the overlay window is somewhere else where it should not be. Usually on top of a different window.
Please help a tired old programmer, who apparently has a pea brain when it comes to coordinate mapping
|
|
|
|
|
Cpt Rick wrote:
// Modeless dialog #1 (which is itself an overlay on main dialog).
CRect rc;
GetWindowRect(&rc);
ClientToScreen(&rc);
// m_EQS is the overlay on the overlay.
m_EQS->SetWindowPos(&wndTop, rc.left+355, rc.top-5, 0, 0, SWP_NOSIZE);
m_EQS->ShowWindow(TRUE);
GetWindowRect returns screen coordinates, but you are applying a ClientToScreen transformation on them. Later, those coordinates are used in the call to SetWindowPos, which for child windows expects client coordinates. I've never worked with those "overlay" dialogs, so I'm not sure whether m_EQS is a child window of the dialog or not. In any case, here's my suggestion.
void YourDialog::SomeMethod()
{
const CSize szOffset(355, -5);
CPoint ptPosition(0,0);
ptPosition += szOffset;
ClientToScreen(ptPosition);
m_EQS->SetWindowPos(&wndTop, ptPosition.x, ptPosition.y, 0, 0, SWP_NOSIZE);
m_EQS->ShowWindow(TRUE);
}
However, using a fixed offset in pixels is problematic. Why don't you use one of the dialog controls as a reference to where to locate the overlay? You may add a not visible static control and use it as a place holder.
void YourDialog::SomeMethod()
{
CPoint ptPosition(0,0);
CWnd* pPlaceHolder = GetDlgItem(IDC_PLACEHOLDER);
ASSERT(pPlaceHolder);
if (pPlaceHolder)
{
CRect rPos;
pPlaceHolder->GetWindowRect(rPos);
ScreenToClient(rPos);
ptPosition = rPos.TopLeft();
}
ClientToScreen(ptPosition);
m_EQS->SetWindowPos(&wndTop, ptPosition.x, ptPosition.y, 0, 0, SWP_NOSIZE);
m_EQS->ShowWindow(TRUE);
}
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Jose:
I tried the second example you gave (BTW: the m_EQS window is a child window of the dialog above it), and got the same results as before when changing the resolution higher (the overlay is down and to the right quite a bit).
The placeholder I used was a static text on the second level window, which I hide when showing the overlay.
Neither of these two windows uses a title or frame - the order they look like is:
-Main Dialog Window for the app
-EQWindow - child of above
-m_EQS - child of above child
It almost seems as if I'm getting the coordinates of one of the other windows in the app when it goes to display the overlay, as I have multiple modeless dialogs being used in this app...
|
|
|
|
|
Let me see if I understood:
Both m_EQS and the placeholder are children of the same window, and that window is an EQWindow , right?
Now, did you tried the sample code in a method of EQWindow , or in a method of the main dialog window? If the former, I can't see why its failing. If the latter, you'd need to modify the calls to ClientToScreen and ScreenToClient so that they refer to the EQWindow (e.g.: m_eqw->ScreenToClient(rPos); and m_eqw->ClientToScreen(ptPosition); )
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Yes to the first question.
Yes to the second, all code dealing with m_EQS is within the EQWindow class.
Like I said, this is why I can't fathom coordinate mapping, it doesn't seem to work as per MSDN rules... I should add that it works until I change the screen resolution, then it fails.
|
|
|
|
|
How can I get a message when clicked on an already selected item in the treeview control? Could anybody help me? Thanks in advance!
|
|
|
|
|
Use a combination of OnMouseDown/Up(), CTreeCtrl::GetSelectedItem(), and CTreeCtrl::GetItemRect().
John
|
|
|
|
|
You can also handle the NM_CLICK notification. Call GetMessagePos to get the mouse coordinates for the message.
|
|
|
|
|
Hi All,
I have a weird situation with me.
I have a hook dll which is hooking message of a process P1.
Now there is another process P2 which actually sets the hook. This P2 is a console application
Whenever a new dialog box pops up in P1, hook dll captures the handle of this new dialog. Now I want to send this handle to a thread created from process P2. How do I? Shared data will work here but in that case process P2 will have to read from dll but I want that whenever a new dialog box pops up in process P1 at that time hook dll should intimate about the same to the thread in process P1. If its a user interface thread then I can do it by posting some WM_USER message. But can I have user interface thread from a console application? (My process P1 is a console application).
Or can I intimate a worker thread in process P1 from hook dll running in context of P2 process.
--------------
Vaibhav...
|
|
|
|
|
I am already thinking your best bet is going to be to set an event that the console will be waiting upon. Put the data from the hook / retrieve the data into the console application from a memory mapped file.
Or else create a named pipe, use a mailslot, etc.
|
|
|
|
|
Hi All,
I would like to know that is it possible to create User Interface Thread from a console application?
I tried doing that but when I am calling obMyDlg.DoModal() from the InitInstance() of my class which is derived from CWinThread thread ends with exit code zero.
Any hints?
--------------
Vaibhav...
|
|
|
|
|
Help!! I really weak in programming and never learn visual c++ before.
I need to write a program to send message using console application.
My program need to send a message to a destination (type the destination IP address).
|
|
|
|
|
|
what is net send? can give me example?
|
|
|
|
|
Hi,
I'm trying to work out how to get the directory name of where my executable is installed. Is this information provided automatically by my installer in the registry somewhere or do I have to manually set this for my installer (I am just using the "Setup Project" from Visual Studio 2003)?
I can get the working directory, but when I have a file association and double-click on that file obviously the working directory gets set to the parent folder of the file and not of my executable.
Thanks in advance.
|
|
|
|
|
|
Does anyone knows how to use SortItems with my ClistCtrl for each column.
I have three column. I need to sort.
I tried what is written in msdn for sortitem but it didnt work (I wrote the exact code)
/\|-||\/|/\|)
|
|
|
|
|
Right Click on the List Control and check "sort" property
V
|
|
|
|