|
there are dozens of fun ways to do this.
the first, like you say, is to just issue a command line command to do it. see the "spawn" function.
the second, C, way to do it is like this:
(off the top of my head, so you'll have to fix any bugs by yourself)
FILE *fp1 = fopen("a:\\test1.txt", "rb");
FILE *fp2 = fopen("a:\\test2.txt", "rb");
FILE *fp3 = fopen("a:\\test3.txt", "wb");
while (!feof(fp1))
{
BYTE c;
c = fgetc(fp1);
fputc(fp3, c);
}
while (!feof(fp2))
{
BYTE c;
c = fgetc(fp2);
fputc(fp3, c);
}
fclose(fp1);
fclose(fp2);
fclose(fp3);
of course this is horribly inefficient. you'd be much better reading and writing large chunks (4K chunks, for example) instead of single bytes (see fread and fwrite).
then there are the C++ ways to do it, with CFile, or the io stream stuff.
all of it is 100% fun.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
In CMainFrame I want to access m_Grid that I have declared global in a CFormView derived class called CTableView. In CTableView I have the declaration:
CMSFlexGrid m_Grid;
But when I for example call m_Grid.GetRows() in CMainFrame I get an error:
'm_Grid' : undeclared identifier..........
What am I doing wrong?, it is another way to access m_Grid from CTableView without making it global?
OyS
|
|
|
|
|
1) First, you have to have a pointer to the view that contains the m_Grid variable. To get one, enumerate through the document templates, and then through the opened documents in each template, and then through the opened views of each document until you get a pointer to the desired view.
2) If the m_Grid variable is not declared public (and it shouldn't be), you either need to make it public, or (better choice) make a public function in your view class that returns the number of rows in the grid.
|
|
|
|
|
Thanks for your interest. Could you please give me an code example of how I get the pointer to the view. That would be very helpful.
OyS
|
|
|
|
|
Have you checked the articles on this web site yet?
|
|
|
|
|
If you want a quick and dirty way to get a pointer to your view you can do this:
MainFrm.h:
CMyView* m_pMyView;
MyView.cpp (in OnInitialUpdate):
((CMainFrame*)(AfxGetMainWnd()))->m_pMyView = this;
Make sure to put class CMyView; above your MainFrame class declaration in MainFrm.h
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Create an instance of your Class CTableView in CMainFrame
..
CTableView tv;
..
access it by typing tv.*
CaKe
|
|
|
|
|
Hi,
I am adding an automatically resizable dialogbar into my MFC program. But it can not automatically resize when the window size is changed. Can you tell me the reason and how to implement this? Thanks in advance.
Kidd
|
|
|
|
|
|
No difference, do you have any idea? Thanx.
Kidd
|
|
|
|
|
How do I change the cursor to the mouse when i drag it over a bitmap/icon. And How do I get an onclick event to the bitmap/icon?
ALB
|
|
|
|
|
To change the cursor take a look at the API LoadCursor(..) and SetCursor(..) i think i done it with them few times ago,
And to the other yust use the WM_RBUTTONDOWN Message...
|
|
|
|
|
To change the cursor take a look at the API LoadCursor(..) and SetCursor(..) i think i done it with them few times ago,
And to the other yust use the WM_RBUTTONDOWN Message...
|
|
|
|
|
I have a single document with a splitter bar. One right view and one left view. In the menu I have several choices. One for example is OnManageUsers().
In the left view I have a CFormView with a button: Users. When I press this button I want to do the same operations as in OnManageUsers(). The problem is that I dont have access to OnManageUsers() from here. The button is a member of CIconView and OnManageUsers() is a member of CMainFrame. How can I access this function?
OyS
|
|
|
|
|
I would post a WM_COMMAND to the main frame.
AfxGetMainWnd()->PostMessage ( WM_COMMAND, ID_MANAGE_USERS );
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
I have a single document with a splitter bar. One left view and one right view. In the right view I have a CFormView where I have placed a FlexGridControl. When I resize the document the Flexgrid doesn't resize. How do I get the flexgrid control to resize?
OyS
|
|
|
|
|
Handle WM_SIZE in CFormView-derived class. In the handler use MoveWindow to change flexgrid size.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi All,
I have a query regarding REGEDT32.EXE .I try to programmatically set value for a field in the Registry.This value is a string value.I am using RegSetValueEx() for this and the the maximum length of this string I am specifying as 256.Now, the problem is when the string length is less than this maximum value after the required string some junk values are put in the REGEDT32.EXE .These junk values should not be there in the value for a field.How can I do this?
When I tried the same in Regedit.exe there is no such problem.Whatever may be the string length there are no junk values in the Regedit.exe.
How has to be done to rectify the problem.I also tried NULL terminating the String.Still the problem persists.
Thanx in advance for the help.
Regards,
yamini.
|
|
|
|
|
The last parameter of RegSetValueEx() isn't a "maximum" length, but the actual length of the string, including the terminating zero.
|
|
|
|
|
Hello,
I add a dialogbar into my MFC program. But after I resize the window, the dialogbar will not resize automatically to fit the changed window. What is the matter? If I must initialize this when I create the dialogbar? How can I? Thanks a lot.
Kidd
|
|
|
|
|
Hi:
Who knows how to judge a dialog is a "File Open" dialog. When I hook the message and capture the WM_INITDIALOG, but I can not kown if the dialog is CFileDialog
Thanks
wq1976
|
|
|
|
|
If you can get a pointer to the dialog (either a CWnd* or a CDialog*) then try this:
if (pWnd->IsKindOf(RUNTIME_CLASS(CFileDialog))
// Is a CFileDialog
else
// Is not a CFileDialog
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Hi:
Recently I study the richeditctrl.I find I can not load the data of object which is in rictedit. For example, If I drop a bitmap into the richedit and modify it in richedit, but I don't have way to load the modified object out and saved it as a bmp file. Who knows?
Thanks
wq1976
|
|
|
|
|
Hi:
Recently I study the richeditctrl.I find I can not load the data of object which is in rictedit. For example, If I drop a bitmap into the richedit and modify it in richedit, but I don't have way to load the modified object out and saved it as a bmp file. Who knows?
Thanks
wq1976
|
|
|
|
|
hi all,
i would like to know how i can kill a thread created by AfxBeginThread(). i tried to use TerminateThread() to kill it. i can compile it but i can't kill.
the code is following,
//begin thread
hThread = AfxBeginThread(receiver, msg);
...
...
//kill thread
DWORD exitcode;
hThread = TerminateThread(hThread, exitcode);
it just don't work... how to do?
i know i can use CWinThread's member function to kill it. but, it make me need so much times to reconstruct my code... do i must do it to solve the problem?
regards,
|
|
|
|