|
I have been looking through the threads of in the board.Can't seems to be able to understand how to do it. I need to get rid of the ugly message in the Title bar with "Untitled - myprogram" and update it with my own message. Anyone that can help me on that?
Please try to include some lines of codes. I am really very new in VC++ 6.0.
Thanks!
|
|
|
|
|
Try looking up SetWindowText in ur MSDN, sorry about lines of code, but its nearly:
in the MainFrame Class or dialog class u call:
SetWindowText ( _T("Ur title") ) ;
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thanks for the information. I was trying a few ways to
do it and it's working!! Just curious, is there anyway I could replace the whole line of the title bar. I mean I could replace the Untitled part, but not able to get rid of
the program name at the end of the string.
|
|
|
|
|
i try to recognize by using space, but unsuccess. it might be the coding error. can someone pls show me the coding.thanks. ur reponse will be appreciated for me.
|
|
|
|
|
you will also have to use punctuation marks such as '.',',',';' etc. Hyphens are also wierd as they can indicate a joining of words or that a word has been split to allow it to wrap at the end of a line (not end of sentence), this normally happens after the 3rd charcter.
eg con-
tinutation
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
Splitting of words happens between two syllables. e.g.: Split-ting, not Spl-itting
|
|
|
|
|
true - but I remember a 3 letter rule as well that you do not break the word if the first part is less than 3 letters but just start it on the next line.
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
can i have a example full source code?
|
|
|
|
|
Somebody is not doing their homework. How do you expect to learn how to program if you dont want to do the work? I sugest switching courses. Youll get no help here.
Heres some assistance though. Define "what" a word is. Is is a series of alpha characters followed by a space or possibly a form of punctuation? . , ; ' : -
or is your programs definition of a word slighly simpler?
can a word have numerical characters in it? is l33t a word?
Ryan Baillargeon
Software Specialist
Fuel Cell Technologies Inc.
|
|
|
|
|
I think you should be misunderstanding, or else it is my fault. i suppose to post my coding and lets you all expertise and checking the error for me. However, the system now is workable for space. one more question is if i would like to get some particular word, lets say 3rd word from the sentence. then what should i add inside?
the following is the coding:
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
#include <cstring>
int main()
{
char string[256];
char *tokenPtr;
cout << "Enter sentence\n";
cin.getline(string,sizeof(string),'\n');
cout << "The string to be tokenized is:\n" << string
<< "\n\nThe tokens are:\n";
tokenPtr = strtok( string, " " );
while ( tokenPtr != NULL ) {
cout << tokenPtr << '\n';
tokenPtr = strtok( NULL, " " );
}
return 0;
}
|
|
|
|
|
I was positioning my richedit so that it hugged the bottom edge of my UI at all times using (in OnSize):
m_editright1.MoveWindow(cx - 200, 390 - VScrollDistance, 200, <code>cy-350+ VScrollDistance</code>);
This works well, but the edge hugged is the visible bottom edge, not the region hidden by the scrollbars of my MFC MDI app. (Strange fact: If I scroll down completely and resize it does elongate (beyond?) to the real bottom edge ). SO in order to make sure I definitely get the bottom hugging behavior (with or without scrolling and resizing) I made the box superlong:
cy+ VScrollDistance .
The problem is that the vertical scrollbars never develop for the control even if I shrink my UI to be less tall and the text gets obscured. If it truly hugged the bottom at all times, I feel the scrollbars would develop. Any ideas on how I can get it to align itself along the TRUE bottom edge of the UI and not just the visible region right from the start.( I do this positioning in the OnSize event which seems to run after OnInitialUpdate, so any positioning I do in the latter will be overridden)?
Thanks,
ns
|
|
|
|
|
Greetings
I have been able to automate Word using my application. I have been able to write three lines of text into it.
Now how should I create tables and format text in it.
Now how should I add tables for formatting.
Ritesh
Below is the code which i am using
=============================================================================
#include <ole2.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
// ******************* Declare Some Variables ********************
// Variables that will be used and re-used in our calls
DISPPARAMS dpNoArgs = {NULL, NULL, 0, 0};
VARIANT vResult;
OLECHAR FAR* szFunction;
BSTR bstrTemp;
// IDispatch pointers for Word's objects
IDispatch* pDispDocs; //Documents collection
IDispatch* pDispSel; //Selection object
IDispatch* pDispActiveDoc; //ActiveDocument object
// DISPID's
DISPID dispid_Docs; //Documents property of Application object
DISPID dispid_DocsAdd; //Add method of Documents collection
//object
DISPID dispid_Sel; //Selection property of Applicaiton object
DISPID dispid_TypeText; //TypeText method of Selection object
DISPID dispid_TypePara; //TypeParagraph method of Selection object
DISPID dispid_ActiveDoc; //ActiveDocument property of Application
//obj
DISPID dispid_SaveAs; //SaveAs method of the Document object
DISPID dispid_Quit; //Quit method of the Application object
// ******************** Start Automation ***********************
//Initialize the COM libraries
::CoInitialize(NULL);
// Create an instance of the Word application and obtain the pointer
// to the application's IDispatch interface.
CLSID clsid;
CLSIDFromProgID(L"Word.Application", &clsid);
IUnknown* pUnk;
HRESULT hr = ::CoCreateInstance( clsid, NULL, CLSCTX_SERVER,
IID_IUnknown, (void**) &pUnk);
IDispatch* pDispApp;
hr = pUnk->QueryInterface(IID_IDispatch, (void**)&pDispApp);
// Get IDispatch* for the Documents collection object
szFunction = OLESTR("Documents");
hr = pDispApp->GetIDsOfNames (IID_NULL, &szFunction, 1,
LOCALE_USER_DEFAULT, &dispid_Docs);
hr = pDispApp->Invoke (dispid_Docs, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_PROPERTYGET, &dpNoArgs, &vResult,
NULL, NULL);
pDispDocs = vResult.pdispVal;
// Invoke the Add method on the Documents collection object
// to create a new document in Word
// Note that the Add method can take up to 3 arguments, all of which
// are optional. We are not passing it any so we are using an empty
// DISPPARAMS structure
szFunction = OLESTR("Add");
hr = pDispDocs->GetIDsOfNames(IID_NULL, &szFunction, 1,
LOCALE_USER_DEFAULT, &dispid_DocsAdd);
hr = pDispDocs->Invoke(dispid_DocsAdd, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD, &dpNoArgs, &vResult, NULL,
NULL);
// Get IDispatch* for the Selection object
szFunction = OLESTR("Selection");
hr = pDispApp->GetIDsOfNames (IID_NULL, &szFunction, 1,
LOCALE_USER_DEFAULT, &dispid_Sel);
hr = pDispApp->Invoke (dispid_Sel, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_PROPERTYGET, &dpNoArgs, &vResult,
NULL, NULL);
pDispSel = vResult.pdispVal;
// Get the DISPIDs of the TypeText and TypeParagraph methods of the
// Selection object. We'll use these DISPIDs multiple times.
szFunction = OLESTR("TypeText");
hr = pDispSel->GetIDsOfNames(IID_NULL, &szFunction, 1,
LOCALE_USER_DEFAULT, &dispid_TypeText);
szFunction = OLESTR("TypeParagraph");
hr = pDispSel->GetIDsOfNames(IID_NULL, &szFunction, 1,
LOCALE_USER_DEFAULT, &dispid_TypePara);
// The TypeText method has and requires only one argument, a string,
// so set up the DISPPARAMS accordingly
VARIANT vArgsTypeText[1];
DISPPARAMS dpTypeText;
bstrTemp = ::SysAllocString(OLESTR("Metallica"));
vArgsTypeText [0].vt = VT_BSTR;
vArgsTypeText [0].bstrVal = bstrTemp;
dpTypeText.cArgs = 1;
dpTypeText.cNamedArgs = 0;
dpTypeText.rgvarg = vArgsTypeText;
//Invoke the first TypeText and TypeParagraph pair
hr = pDispSel->Invoke (dispid_TypeText, IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&dpTypeText, NULL, NULL, NULL);
hr = pDispSel->Invoke (dispid_TypePara, IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&dpNoArgs, NULL, NULL, NULL);
::SysFreeString(bstrTemp);
//Invoke the second TypeText and TypeParagraph pair
bstrTemp = ::SysAllocString(OLESTR("Pantera"));
hr = pDispSel->Invoke (dispid_TypeText, IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&dpTypeText, NULL, NULL, NULL);
hr = pDispSel->Invoke (dispid_TypePara, IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&dpNoArgs, NULL, NULL, NULL);
::SysFreeString(bstrTemp);
//Invoke the third TypeText and TypeParagraph pair
bstrTemp = ::SysAllocString(OLESTR("Godsmack"));
hr = pDispSel->Invoke (dispid_TypeText, IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&dpTypeText, NULL, NULL, NULL);
hr = pDispSel->Invoke (dispid_TypePara, IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&dpNoArgs, NULL, NULL, NULL);
::SysFreeString(bstrTemp);
// Get IDispatch* for the ActiveDocument object
szFunction = OLESTR("ActiveDocument");
hr = pDispApp->GetIDsOfNames (IID_NULL, &szFunction, 1,
LOCALE_USER_DEFAULT,
&dispid_ActiveDoc);
hr = pDispApp->Invoke (dispid_ActiveDoc, IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
&dpNoArgs, &vResult, NULL, NULL);
pDispActiveDoc = vResult.pdispVal;
//Set up the DISPPARAMS for the SaveAs method (11 arguments)
VARIANT vArgsSaveAs[11];
DISPPARAMS dpSaveAs;
dpSaveAs.cArgs = 11;
dpSaveAs.cNamedArgs = 0;
dpSaveAs.rgvarg = vArgsSaveAs;
BSTR bstrEmptyString;
bstrEmptyString = ::SysAllocString(OLESTR(""));
VARIANT vFalse;
vFalse.vt = VT_BOOL;
vFalse.boolVal = FALSE;
bstrTemp = ::SysAllocString(OLESTR("c:\\doc1.doc"));
vArgsSaveAs[10].vt = VT_BSTR;
vArgsSaveAs[10].bstrVal = bstrTemp; //Filename
vArgsSaveAs[9].vt = VT_I4;
vArgsSaveAs[9].lVal = 0; //FileFormat
vArgsSaveAs[8] = vFalse; //LockComments
vArgsSaveAs[7].vt = VT_BSTR;
vArgsSaveAs[7].bstrVal = bstrEmptyString; //Password
vArgsSaveAs[6].vt = VT_BOOL;
vArgsSaveAs[6].boolVal = TRUE; //AddToRecentFiles
vArgsSaveAs[5].vt = VT_BSTR;
vArgsSaveAs[5].bstrVal = bstrEmptyString; //WritePassword
vArgsSaveAs[4] = vFalse; //ReadOnlyRecommended
vArgsSaveAs[3] = vFalse; //EmbedTrueTypeFonts
vArgsSaveAs[2] = vFalse; //SaveNativePictureFormat
vArgsSaveAs[1] = vFalse; //SaveFormsData
vArgsSaveAs[0] = vFalse; //SaveAsOCELetter
//Invoke the SaveAs method
szFunction = OLESTR("SaveAs");
hr = pDispActiveDoc->GetIDsOfNames(IID_NULL, &szFunction, 1,
LOCALE_USER_DEFAULT, &dispid_SaveAs);
hr = pDispActiveDoc->Invoke(dispid_SaveAs, IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&dpSaveAs, NULL, NULL, NULL);
::SysFreeString(bstrEmptyString);
//Invoke the Quit method
szFunction = OLESTR("Quit");
hr = pDispApp->GetIDsOfNames(IID_NULL, &szFunction, 1,
LOCALE_USER_DEFAULT, &dispid_Quit);
hr = pDispApp->Invoke (dispid_Quit, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD, &dpNoArgs, NULL, NULL, NULL);
//Clean-up
::SysFreeString(bstrTemp);
pDispActiveDoc->Release();
pDispSel->Release();
pDispDocs->Release();
pDispApp->Release();
pUnk->Release();
::CoUninitialize();
return 0;
}
|
|
|
|
|
http://www.codeproject.com/com/xoffice.asp
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
It looks like you have a working technique to communicate with the Word app. If you are asking about the specific commands to issue to word to create the table and do the formatting, I suggest you let the Word program tell you.
Turn on the macro recorder, perform the operations of interest (create table). Then turn off the recorder and read the macro. It will contain the commands you need to implement. The implementation is just like the stuff you already have coded.
|
|
|
|
|
Thanks...I will take a look at it.
Ritesh
|
|
|
|
|
I have written a Server Client Chat Program using CAsyncSocket. I can get the Remote Hosts I.P. Address using the GetPeerName() Function. I also want the Host Name. To do this I sent a message with the OnConnect() and OnAccept() functions. This only works intermittently and if I disconnect the Client Leaving the Server Listening and then re-connect it does not work at all. What is a better and more reliable way to do this?
|
|
|
|
|
getnameinfo (WinSock2) returns the hostname for a given IP-address
(gethostbyaddr is simpler in usage, but deprecated)
|
|
|
|
|
You guys are all familiar with SDI and MDI models of application design (ie Document View Architecture).
Im reading through Prosise (MFC) and came across this:
Alternatives to MDI
A workspace-based model that groups related documents in objects called worspaces and allows documents
contained in a workspace to be viewed and edited in MDI-like document frames that are children of a top
level frame window. Visual C++ is one example of an application that uses the workspace
containment model. I would be interested to know if anyone has had any success programming an application with a model similar
to this. I am interested in this model mainly because the application I am designing is going to need
"modular" documents. That is, a user is going to be able to add many different types of documents to their
workspace. The workspace object will need to be serialized so that it can be saved and loaded. Its a major
undertaking because there is also a document designer application that the user can use to generate active
documents that can be loaded into the workspace. These documents are just "views" of data objects that will
also have to be serialized along with a workspace.
In other words containment is
workspace
--> multiple data objects (dynamically added)
--> multiple documents (views) (dynamically added)
Has anyone seen or read any articles on this style? Seen any similar open source projects / examples? The
model has also been called the "floating Document Interface". Apparantly CodeWarrior uses it as a
stock programming model (along with MDI / SDI).
Ryan Baillargeon
Software Specialist
Fuel Cell Technologies Inc.
|
|
|
|
|
Has anyone even read this?
Ryan Baillargeon
Software Specialist
Fuel Cell Technologies Inc.
|
|
|
|
|
|
I have a loop that first gets a value of "PAGE" for the Cedit WindowText. Why doesnt it stop at
GetWindowText() the second time it comes around? I stepped through and after finding "PAGE" the first time, it sails through the lines in red on a second pass, and of course I never got a chance to change the CEdit entry, so the variable is still "PAGE", and an infinite for loop starts....
bool bExistingEntry;
do
{
<code> m_editAddNewKeyword.SetFocus();
m_editAddNewKeyword.GetWindowText(m_newKW);</code>
bExistingEntry = false;
for (int i = 0 ; i < m_numFields && !bExistingEntry ; i++)
if (bExistingEntry = (m_AddKWFldsHolder[i] == m_newKW))
{
AfxMessageBox("Keyword already exists in database. Add new Keyword or Cancel");
}
}
while (bExistingEntry);
Probably something goofy, but I cant see it....
Thanks,
ns
|
|
|
|
|
It does!! GetWindowText() just gets the text from the edit control into m_newKW . The proper way to validate input is in your dialog's OnOK() handler. Like so:
m_editAddNewKeyword.GetWindowText (m_newKW);
for (int i = 0 ; (i < m_numFields); i++) {
if (m_AddKWFldsHolder[i] == m_newKW) {
AfxMessageBox("Keyword already exists in database. Add new Keyword or Cancel");
return;
}
}
CDialog::OnOK();
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
How do I get my UI to pop up again after the messagebox is dismissed. I cant dismiss the messagebox, it keeps looping because I never get a chance to change the entry. I thought setfocus would do it, but it sails through that line I found...
|
|
|
|
|
See my edited reply. I figured I'd left out the essentials.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
thanks a bunch! I didnt think of that!
|
|
|
|
|