|
Hello,
I was trying to add a child window to another window that is not running with the same application instance. I used enumWindows to find the window I was looking for and then used createWindowEx to create the child window specifying the window handler that was found as the parent. It didn't work.
Is this possible?
thanks.
|
|
|
|
|
You said it didn't work what did you get error or a null handle.
|
|
|
|
|
I'm new in ATL control programming, I did write some ActiveX Controls, so I started with ATL Controls project intuitively, and I start find some problems.
Ie:
I'm developing an ATL Control with MFC support and a Composite Control.
Then I put a button and I write code for OnButton like that:
<br />
LRESULT OnClickedButton1(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)<br />
{<br />
AfxMessageBox("Hello");<br />
return 0;<br />
}<br />
That work fine using the control in a VB application.
But if I add a Dialog class and handle the OnButton1 in the CDialog class, the button do nothing when it's pressed in a VB application.
I know, I miss something to tell the control that the handle is in the Dialog class, but what?
I need the dialog class because I will have more controls there and members variables and more handles for every control.
I would really appreciate any help, meanwhile I'm going to read some ATL articles.
Thank you.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
hi
need a little help as new to c++.
when i run the code below to save the names to a text file and then output the names back to the console application i have all the names together with no spaces.
eg: markjohnpeterjames
what i need to know is there a way to output the data from the txt file to the console but with spaces between the names ( or if you can play around with the output format in general ) or is it possible to save them to the text file in a particular format ?????
This one has me stuck !!!!!
Plus any sugestions for improvements on the code below will be much appreciated.
char xx [20];
ofstream fout;
fout.open("c:/out.txt", ios::app);
cout<< "Please enter your first name: \t";
cin>> xx;
fout<< xx;
// close file
fout.close();
char yy;
ifstream myfile("c:/out.txt");
cout<< "\nAll names entered on file: \t";
while (!myfile.eof())
{
myfile>> yy;
cout<< yy;
}
Thanks in advance !!!!
The problem with political jokes is they get elected.
|
|
|
|
|
When wring the file, write the name in either of the following ways:
fout << name << endl;
four << name << " ";
For print the file to the screen:
#include <iterator>
#include <algorithm>
#include <vector>
#include <string>
vector<string> names;
copy(istream_iterator<string>(myFile), istream_iterator<string>(), back_inserter(names));
copy(names.begin(), names.end(), ostream_iterator<string>(cout, "\n"));
Note that depending on the version of your compiler/STL library, it may or may not have overrides for reading string types in this manner, in which case you would need to switch it to a vector of character buffers of some size.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hi Zac
The input and output format issues are working ok now thanks, but one small issue and i dont know why its happening.
The last name that i enter is saved to the text file no problems but is always printed twice on the console application after the program is run ????? ( only saved once on the text file!!!! )
eg:
mark
peter
james
james
Any suggestions why this might be the case.
Sorry for the hassle.
The problem with political jokes is they get elected.
|
|
|
|
|
What does your code look like exactly?
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
char xx [20];
ofstream fout;
fout.open("c:/out.txt", ios::app);
cout<< "Please enter your first name: \t";
cin>> xx;
fout<< xx << endl;
fout.close();
char yy[100];
ifstream myfile("c:/out.txt");
cout<< "\nAll names entered on file: \t";
while (!myfile.eof())
{
myfile.getline(yy,100,'n');
cout << yy;
}
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Sorry Zac
Your last message just crossed the one i sent and it solved the issue.
Thanks for the code.
Thanks again for your time and help.
The problem with political jokes is they get elected.
|
|
|
|
|
Thanks EricDV
Will have a read up on the getline function
Thanks for looking at my code
I really hate this darn machine;
I wish that they would sell it.
It won't do what I want it to,
but only what I tell it.
~Author Unknown
|
|
|
|
|
I'm fairly new here too, but - welcome to The Code Project.
This site is great.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
EricDV
Quick question with your code.
char yy[100];
ifstream myfile("c:/out.txt");
cout<< "\nAll names entered on file: \t";
while (!myfile.eof())
{
myfile.getline(yy,100, 'n');
cout << yy;
}
In the following line:
myfile.getline(yy,100, 'n');
When i enter a name beginning with the letter "n" like nigel on the console it saves as "nigel" no problems to my text file, but when i display the contents of the text file back into the console it seems to ignore the "n" and output is displayed as "igel". It seems like it is acting as an ignore function. Any ideas why or how to solve it.
Cheers
I really hate this darn machine;
I wish that they would sell it.
It won't do what I want it to,
but only what I tell it.
~Author Unknown
|
|
|
|
|
Mark_Murphy wrote: myfile.getline(yy,100, 'n');
That should be myfile.getline(yy, 100, "\n"), or simply myfile.getline(yy, 100); ('\n' is the default 3rd parameter).
Alternatively, you could use the generic getline method:
string name;<br />
getline(myfile, name);
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Excellent Zac
The
string name;
getline(myfile, name);
worked perfect, the other suggetions gave errors on compiling.
Leave you guys in peace now
Thanks for the help much appreciated !!!
I really hate this darn machine;
I wish that they would sell it.
It won't do what I want it to,
but only what I tell it.
~Author Unknown
|
|
|
|
|
Oops...sorry, I don't really use this stuff.
Should've been:
myfile.getline(yy,100,'\0');
This way the file read will quite when it hits a null char.
SEE:
Input Stream Member Functions[^]
and
istream::getline[^]
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
No worries EricDV
Thanks for the info and the links, will go read up the stuff for a while now ( maybe confuse myself a little further lol ). Its been 4 days now since i started with C++ and just finished my first program. All I got to do now is tweak the code a little and try to improve it.
So many thanks for your help today !!!!
I really hate this darn machine;
I wish that they would sell it.
It won't do what I want it to,
but only what I tell it.
~Author Unknown
|
|
|
|
|
if project had multi CDocument class which class is first handle
menu massage such as Open File ....
i try that my default class is CFirstDocument , other is CMyDocument ,
i i create menu as name "Open Image File..." & handle message in CMyDocument
when program execute ,"Open Image File..." is disable !!!
but when i handle it from CFirstDocument that is active !
how can i change these setting & what is order of handling messege in these case?
Best Regards.
MJM.
|
|
|
|
|
I don't have a Windows platform around to verify this, but I *believe* that the first document template you add to the app in InitInstance() method will be the default document type. Change that order if it is not the document type of your choice.
Best,
Jun
|
|
|
|
|
i change order but nothing happen!
i try to search to how order for handling messages!
for MDI:
1)active view object
2)the document object for the active document
3)the document template object for active document!!!
4)the frame window object of active view
5) main frame window object
6)the application object
// Thanks Ivor Horton's book!
for sdi because have one active frame it is obviously what order is!
in my code i have Dockable window that create dynamically .
in my code with CCreateContext & CFrameWnd::Create... create Frame & related view & attach them to document dynamically!
it is seems that when i create new Frame can not be active frame because after i create pane i
get active view for MDI code such that:
<br />
CMDIFrameWnd *pFrame1 = <br />
(CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;<br />
<br />
CMDIChildWnd *pChild = <br />
(CMDIChildWnd *) pFrame1->GetActiveFrame();<br />
<br />
<br />
CView * pView = pChild->GetActiveView();<br />
after debug i see pView is kind of another view that i create for pane!!!!
i try to active new frame with pFrame->GetParentFrame()->ActiveFrame(SW_RESTORE);
but nothing happen.
i have tree view class & two Document class & three template.
|
|
|
|
|
You have not specified whether the application is SDI or MDI and you have not specified what each document is for.
Is this a MDI application and is each child window a separate image? If so, then perhaps an article I wrote would help. Otherwise explain a bit more what the application is doing, especially about how the document is used.
|
|
|
|
|
File-Open is usually handled by the main frame. If you have multiple document types then the statndard behaviour is present to the user a dialog where they can choose which document type to open. The same applies for File-New.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
after some try i found , error is from my view class !!!
default CView class work properly !!! but own class that
i derived have problem when i try to OpenDocument from another
template , other CView do not work properly!
|
|
|
|
|
OK guys I received a project from a buddy, needs some work on it; however it's a sln project file in 2005 and I use 2003. I really do not want to have to install 2005, as I have no need to upgrade right now. I have seen other converters, but none to go from 2005 to 2003. Is there any other solution? Thanks.
|
|
|
|
|
I don't know of a converter, but my past experience with similar converted has been that it's better to recreate the base project with the previous IDE and then bring the files in.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
how to write a code to control the surround volumn for each?
please give me some idea and example
|
|
|
|