|
A message loop is the same irrespective of whether it is for a parent window or a child window or a window in another thread.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Let me descrip my problem more precisely:
Window->Childwindow(Tab control)->ChildWindow1(edit control).
In windows message loop
{
case WM_NOTIFY:
{
switch(nmhdr->idFrom)
{
case IDC_MAIN_TREEVIEW: //childwindow's Id
switch(nmhdr->code)
{
//I am expeccting notify messages from ChildWindow1?
}
}
}
}
Please let me know weather i am doing correctly.?
Birajendu
SonicWALL
Bangalore
India
|
|
|
|
|
birajendu wrote: In windows message loop
Do you mean in the message loop or in the WNDPROC for Window (I think it's the second one).
birajendu wrote: //I am expeccting notify messages from ChildWindow1?
No - they get sent to the Tab control - which has a different WNDPROC. You need to subclass it so that you can process the window messages sent to it. See the message I previously posted about subclassing windows.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
The message loop will handle all windows created on the thread it's in (a simplification, but close enough).
To modify the behaviour of the child windows, you need to subclass them, to handle messages sent to them differently than the default. I would suggest you read up about window subclassing - this[^] is a good starting point.
For example, to subclass a tab control created in your topmost window, you might use this to create and then subclass the control.
RECT rcCLient;
GetClientRect(hWnd, &rcCLient);
hwndTab = CreateWindow(WC_TABCONTROL, _T("tab"), WS_VISIBLE|WS_CHILDWINDOW, 0, 0, rcCLient.right, rcCLient.bottom, hWnd, 0, hInst, 0);
oldTabProc = (WNDPROC)::SetWindowLongPtr(hwndTab, GWLP_WNDPROC, LONG_PTR(&TabWndProc));
This next code fragment is my definition of a window procedure for the tab control that will forward notifications from an edit control contained inside it to the tab control's parent window. It's a bit evil, 'cause it uses a global for the tab control's old WNDPROC, but it illustrates the point.
WNDPROC oldTabProc;
LRESULT CALLBACK TabWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_COMMAND && HWND(lParam) == hwndEdit)
return ::SendMessage(GetParent(hWnd), message, wParam, lParam);
return oldTabProc(hWnd, message, wParam, lParam);
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks a Lot. This served my purpose....
Birajendu
SonicWALL
Bangalore
India
|
|
|
|
|
I want to redirect Telnet and Ftp to my program.I have tried using pipe to redirect cmd.exe.All commands can be executed well except Telnet and Ftp commands.
Waiting for help!
|
|
|
|
|
Try to be a little more explicit - what erroneous behaviour are you seeing with Telnet and FTP?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Even the action of getting into the telnet mode is failed.
The correct answer should be the following:
C:>telnet 127.0.0.1
Telnet>
Telnet>
But mine is:
C:>telnet 127.0.0.1
C:>
Getting nothing!The same problem with ftp.
|
|
|
|
|
It's probably because it's got no standard input connected on startup.
Also - you don't need a cmd.exe for telnet & ftp so long as you supply it with pipes for standard input and standard output. You can give it commands over standard input and gather output using standard output.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello,
I have a class TableFrame
class TableFrame : public CMDIChildWnd
{
}
I have written the following code in MainFrame where OpenNewWindow function opens a new window and WhichNewWindow function gets the active window and calls the function of TableFrame.But I am not etting the pointer of TableFrame and STATIC_DOWNCAST gives Unhandled Exception.
How do I et the active window pointer of TableFrame.
void MainFrame::OpenNewWindow()
{
CMDIChildWnd* ChildPt = CreateNewChild(RUNTIME_CLASS(TableFrame),
TITLE_MachineOpHrs, m_hMDIMenu, NULL);
TableFrame* pF = STATIC_DOWNCAST(TableFrame,ChildPt);
}
void MainFrame::WhichNewWindow()
{
CWnd* p = GetActiveWindow();
TableFrame* pT = STATIC_DOWNCAST(TableFrame,p);
pT->Insert();
}
Thanks
Pritha
|
|
|
|
|
prithaa wrote: CWnd* p = GetActiveWindow();
GetActiveWindow return the pointer the currently active toplevel window. not a child of mdi window.
You should try
TableFrame* pT = (TableFrame*)GetActiveFrame();
|
|
|
|
|
|
Hi,
i have a WCHAR variable and i need to pass it as an argument to a function which asks for CString&...
WCHAR buf[10];
void xxx::yyy(CString& rString)
i need to pass this buf in the place of rString...
can anyone help me to convert this?
Thanks,
Rakesh.
|
|
|
|
|
If the function expects a CString, you should pass in a CString.
So simply create a CString variable and pass that in.
CString str;
xxx:yyy(str);
If you want the value in buf, you can later copy it.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi Superman,
Thanks for your reply...
i actually want to read the content of a file...
If i use CString it is retrieving only the file name and not file content... rather if i use getbuffer() method, i think i can get the content..but its not accepting if i give like this xxx:yyy(str.getbuffer()) ..........it threw an error stating it cant convert wchar_t * to cstring&....
my doubt is this.. i need to copy the content of the file to that wchar variable as well as it should be passed into the function of type cstring&..
how can we do that sir?
Thanks,
Rakesh
|
|
|
|
|
Rakesh5 wrote: if i give like this xxx:yyy(str.getbuffer())
Arghh.... Never nevver use GetBuffer without having read the documentation of that function first. It doesn't make any sense to call this function here because the CString object already provides a cast operator to the same string type returned by the GetBuffer function. So, if passing the CString object directly is failing, calling the GetBuffer function will fail in the same way. Besides, doing that is really bad practice because this function is only inteded to get a way to access the internal buffer of the CString object, which is almost never needed (only in very rare conditions).
|
|
|
|
|
You *must* read the article pointed out by Cedric in his other reply to you.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Why are you using a WCHAR array instead of a TCHAR array in the first place ?
I suggest you read this article[^] first, to be able to understand the concepts. Things will probably be much clearer afterwards.
|
|
|
|
|
Thanks Moonen..
I really appreciate your timely help...
Thanks,
Rakesh
|
|
|
|
|
The function takes a reference to a CString object. You cannot, therefore, pass anything else to it. Please buy a book on C++.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi,
I have created a Window UI using CreateWindowEx(), than on top of that I created a Tabbed control using the same function. On each tab i have a edit control, I am not getting the messages from the edit control.
I am expecting that the mesaages should come to WM_COMMAND/WM_NOTIFIY of the parent window.
thanks in advance.
Birajendu
SonicWALL
Bangalore
India
|
|
|
|
|
Code 1:
while(TRUE)
{ ..........
}
if(1) { ......... }
Compiler warning:- Constant data in conditional statement.
How to get rid of this?
Can i do like.....
bool flag = TRUE;
while(flag) {.......}
Code 2:
unsigned short a = -1;
Compiler warning:- Possible loss of data...
How to get rid of this warning?
Can i do.....
unsigned short a = (ushort)-1;
Code 3:
char a[10];
char b[20] = "H";
strcpy(&a[2], b);
Now i want to convert this function to strcpy_s, where in i have to pass the buffer size..
so can i do like...... strcpy_s(&a[2], sizeof(a), b);
Can i do like that? Or is that i just need to pass the sizeof that particular array index, like sizeof(a[2])
Any help is welcome....
Thanks in advance.
|
|
|
|
|
Hi,
AFAIK there is only one way to create an "eternal loop" that should never generate a warning, whatever smart the compiler is:
for( ; ; ) {
...
}
since this is legal C/C++ code that clearly shows no exit condition. Everything else, checking on 1 or TRUE or a variable with a constant value, is bound to be flagged when compilers are smart enough, their intent is to WARN you that maybe you made a mistake.
The same holds true for empty loops:
while (someCondition); may generate a warning (unintentional empty loop, maybe due to an extraneous semi-colon), whereas
while (someCondition) {}
is fine since now the compiler must realize you typed two characters to create an empty code block.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
dipuks wrote: unsigned short a = -1;
Compiler warning:- Possible loss of data...
How to get rid of this warning?
This is absurd. Why do you want to assign a signed value to unsigned type? What's wrong in using just short ?
|
|
|
|
|
N a v a n e e t h wrote: This is absurd. Why do you want to assign a signed value to unsigned type?
This is not as uncommon as you might think.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|