|
Hi Gurus,
How to get control panel object? Actually i want to add a atb control
to control panel / display properties, Can any body tell me how to proceed?
I think it is possible by getting control pnel object from that by getting
Display properties object, then only there is a chance of adding a tab control
to diaplay properties.
Is there any possibility to get control panel's object through Ishellbrowse,
IShellview etc.
If anybody have an idea, send me links or articles.
Thanks in advance,
Koteswara
|
|
|
|
|
I've tried to store the windows location/size in the registry, and it appears to save the right numbers, but when I read them back in and call MoveWindow it seems to change the numbers. Is move window the right function to call for this, or am I saving the wrong postion using by calling GetWindowRect? I'm pretty sure that its not any of the code that is wrong, but rather that I'm not saving the right numbers.
thanks tyler.
|
|
|
|
|
There are a few possible issues.
1/ Where are you setting the position
2/ what sort of co-ordinates are you saving ( relative to window or relative to dialog ) ? ClientToScreen will convert your co-ordinates to ones relative to the whole window
3/ Have you checked the values going in and coming out to make sure you're reading them correctly ?
4/ Are you passing them in correctly ( MoveWindow takes a width and height, rather than x2, y2. )
|
|
|
|
|
ah yeah, MoveWindow takes width and height and not x2, y2.
I wish I remembered that.
I did this once in MFC though the same way with MoveWindow using GetWindowRect but when looking back through the code I missed the rect.Width(), and rect.Height() instead of just a RECT structure passing the bottom and right.
thanks for the help.
|
|
|
|
|
You may also try with Get/SetWindowPlacement() .
If you save and restore all its fields you can also restore minimized/maximized state.
Cheers
Paolo.
|
|
|
|
|
I suggest that you should read the topic about Persistent Frames in the book Inside Visual C++ from Kruglinsky from Microsoft Press.
|
|
|
|
|
to save the Window position :
WINDOWPLACEMENT pwp;
BOOL ret;
ret = GetWindowPlacement(&pwp);
CString strBuffer;
strBuffer.Format("%i %i %i %i %i %i %i %i %i %i",
pwp.flags, pwp.showCmd,
pwp.ptMinPosition.x , pwp.ptMinPosition.y ,
pwp.ptMaxPosition.x , pwp.ptMaxPosition.y ,
pwp.rcNormalPosition.left , pwp.rcNormalPosition.top ,
pwp.rcNormalPosition.right , pwp.rcNormalPosition.bottom);
AfxGetApp()->WriteProfileString("Settings","windowPos",strBuffer);
to restore the window position :
WINDOWPLACEMENT pwp;
CString strBuffer = AfxGetApp ()->GetProfileString("Settings","windowPos");
int cRead = _stscanf(strBuffer,"%i %i %i %i %i %i %i %i %i %i",
&pwp.flags,&pwp.showCmd,
&pwp.ptMinPosition.x , &pwp.ptMinPosition.y ,
&pwp.ptMaxPosition.x , &pwp.ptMaxPosition.y ,
&pwp.rcNormalPosition.left , &pwp.rcNormalPosition.top ,
&pwp.rcNormalPosition.right , &pwp.rcNormalPosition.bottom);
if (cRead == 10) SetWindowPlacement(&pwp);
|
|
|
|
|
thanks a lot, this is much better than what I was doing previously.
|
|
|
|
|
Just one thing that you forgot, when you restore the window's position you need to set pwp.length = sizeof(pwp) for anybody else that sees this.
Tyler.
|
|
|
|
|
As you probably noticed from this post I am a very new newbie to VC++. Here is my problem. I need to read in a test file that might have a format like this... string, int, int. I know in java you can use a string tokenizer to read in each value separatly and by line. I can't seem to figure this out in C++. This is what I have been doing.
CFile myFile("test.txt", CFile::modeWrite);
BYTE buffer[4096];
CString input;
input = myFile.Read(buffer, 4096);
Once I get it into a string object I can use the method SpanExcluding to get a string from the beginning to the first character I specify not to read. I can't seem to get past it thought. I know my approach is probably all wrong so I don't care if you tear it to shreads. I frequently visit this site and know you guys know what you;re doing so thanks for any advice in advance.
Joshua
|
|
|
|
|
Joshua, use CStdioFile instead of CFile; it lets you read in a line at a time.
For grabbing the tokens, you can use the CRT function strtok(), or the undocumented MFC function AfxExtractSubString(). You use the function thus:
// assuming you have a CString sLine that holds the next line...
CString sStringToken, sIntToken1, sIntToken2;
AfxExtractSubString ( sStringToken, sLine, 0, ',' );
AfxExtractSubString ( sIntToken1, sLine, 1, ',' );
AfxExtractSubString ( sIntToken2, sLine, 2, ',' );
The prototype for AfxExtractSubString() is:
BOOL AfxExtractSubString(CString& rString, LPCTSTR lpszFullString, int iSubString, TCHAR chSep = '\n');
where rString is where the token is placed, lpszFullString is the string to search, iSubString is the token to pull out (a 0-based count), and chSep is the delimiter character.
|
|
|
|
|
Thanks for the insight. This is exactly what I was looking for, I just didn't know where to go. Thanks again for your time.
Joshua
|
|
|
|
|
To add to what Michael has given you...
Text file are usually much easier to handle if you use CStdioFile instead of CFile. CStdioFile allows you to easly read each line in a loop. For example...
CStdioFile f; // construct a CStdioFile object
char buffer[256]; // define a temp buffer
while (f.ReadString(szBuffer, 255))
// tokenize string and process
Roger C.
|
|
|
|
|
Thank you also Roger. This is exactly the help I was looking for. I works great.
Joshua
|
|
|
|
|
I have created an in invisible button (overridden CButton) , and I want to send the buttons messages to the parent ( a CView ) I found an article in MSDN that describes how to do this , but I cannot seem to get it to work. Message Reflection ??? I want all the instances of the class to send the messages to the parent.
Any Ideas anyone ???
|
|
|
|
|
I inserted an ActiveX Control "Microsoft Forms 2.0 TextBox" in my app because it supports unicode character. I can successfully type and retrieve the text from it.
But now I can't set the text to it from the code. I tried using the following code, but it doesn't work. There must be something simple that I am missing. Can anyone help me?
m_myTextBox.SetText(L"The text");
UpdateData(false);
|
|
|
|
|
try:
m_myTextBox.UpdateData(FALSE);
|
|
|
|
|
A server knows the client is present or not by using reference counting. But how knows the server when a client crashes. In that case the client is not able to call Release.
|
|
|
|
|
Hi!
To have a first sample for the XML control I downloaded the
"MFC XML Tree" sample and compiled it using Visual C 5. Doing that gave me the following errors:
D:\test\MFC Tree\Debug\MSXML.tlh(785) : error C2504: 'IXMLDOMCharacterData' : Basisklasse undefiniert
D:\test\MFC Tree\Debug/MSXML.tli(720) : error C2664: '_com_issue_errorex' : Konvertierung des Parameters 2 von 'struct MSXML::IXMLDOMText *const ' in 'struct IUnknown *' nicht moeglich
Compiling the sample using Visual C 6 works well.
Any ideas or hints how to use the XML control with Version 5?
Thank you!
Ciao,
Alex
|
|
|
|
|
The MSDN documentation says that when you programmatically retrieve the fixed file info from a version resource, it comes in a VS_FIXEDFILEINFO structure, which contains a 64-bit date stamp for the file:
- dwFileDateMS
- Specifies the most significant 32 bits of the file's 64-bit binary creation date and time stamp.
- dwFileDateLS
- Specifies the least significant 32 bits of the file's 64-bit binary creation date and time stamp.
However, if I retrieve this resource from an MFC project using code like this:
bRetCode = VerQueryValue(pVffInfo,
_T("\\"),
reinterpret_cast<LPVOID *>(&lpVersion),
&uVersionLen);
if (bRetCode && uVersionLen && lpVersion) {
VS_FIXEDFILEINFO * pFFVer =
reinterpret_cast<VS_FIXEDFILEINFO *>(lpVersion);
FILETIME ftime;
ftime.dwHighDateTime = pFFVer->dwFileDateMS;
ftime.dwLowDateTime = pFFVer->dwFileDateLS;
}
then both ftime.dwHighDateTime and ftime.dwLowDateTime are zero.
Does anyone know anything about what the deal is here? Is there some way I can set the date/time stamp when I build my code and then retrieve it at run-time for the About Box?
Otherwise I could use the __DATE__ and __TIME__ macros in my code, but that would only tell me when a particular module was compiled. I was hoping that there was a good way to get the approximate time the build finished.
|
|
|
|
|
The reason why the date is zero is that in VC++ there isn't any default update of the version resource. You MUST do it yourself.
Mr. Mike Woodring has created an Add-In which does this! It's called BuildNum. You can download it from http://www.bearcanyon.com/
// Mike
|
|
|
|
|
How do I manually update the version resource? I don't see anything in the MSDN documentation about setting the Date/Time in the Version Resource.
I have a fairly complicated Version resource in MyProject.rc2, which sets the version number, build flags, and related things in the version resource using the preprocessor, so I don't want to play with a third-party add-in that will have unknown interactions with my own stuff.
If someone could point me to where I could find out how to manually set the date/time for the dwXxxDateTime fields, I'd be quite grateful.
|
|
|
|
|
Has anyone know how to make a toolbar in the scrollbar,like the Microsoft's Word has two toolbar in vertical and horizontal scrollbar.
Thanks.
|
|
|
|
|
I am trying to write a DCOM server application. Some of the interface functions have paramaters that are user defined data types (structs). I have the header files where these type definitions are included in the server .h file included in the .h file of the server .cpp file. When I try to build, I receive the following error that points back to the .idl file:
"Expecting type specification near "data_type".
Any advice on how to remedy this. I am fairly new to DCOM/COM programming.
|
|
|
|
|
Nevermind, I answered my own question.
|
|
|
|