|
Hi All,
I have a class derived from CFormView.
I have to show ToolTip for some buttons for the view drived from CFormView.
I have done the below steps but, the tool tip is not showing...
Say m_ToolTip is an object for CToolTipCtrl,
In OnInitialUpdate()
m_ToolTip.Create(this);
m_ToolTip.Activate(TRUE);
CRECT rect(1, 1, 1, 1);
m_ToolTip.AddTool(this, "My Tool Tip", &rect, BTN_ID);
In OnSize()
m_ToolTip.SetToolRect(this, BTN_ID, &newRect);
In PreTranslateMessage()
if (pMSg->Message == )
m_ToolTip.RelayEvent(pMSG);
Is there any thing to do more.. or i'm wrong in some where...
Do your Duty and Don't expect the Result
|
|
|
|
|
AFAIK, you forgot to handle notifications (WN_NOTIFY) for the parent window of every control you have handle assigned to.
Regards
|
|
|
|
|
Hello All,
I have small and simple COM program to access a Add function in Dll and I am accessing this function from main program. For the simple add function it is working, interface and dll files are working properly.
For this interface I am trying to add one more function by name getdate() which of return Char* .. can any one please help how to declare the getdate() function in interface ???
Below are declaration and files with there names ….
// File interface.h
// This file contains interface related declarations.
#ifndef _A_INTERFACE_H_
#define _A_INTERFACE_H_
DECLARE_INTERFACE_(IMyA,IUnknown)
{
STDMETHOD_(LONG,MyAdd)(INT,INT) PURE;
};
--- ---
--- ---
file :- MyA.h
class CMyA : public CCmdTarget
{
DECLARE_DYNCREATE(CMyA)
CMyA();
-- -- -- - - -- -- -- - -
-- -- -- - - -- -- -- - -
-- -- - -
-- -- - --- -- -- - --- -- -- - -
protected:
virtual ~CMyA();
DECLARE_MESSAGE_MAP()
BEGIN_INTERFACE_PART(MyAObj,IMyA)
STDMETHOD_(LONG,MyAdd) (INT,INT);
END_INTERFACE_PART(MyAObj)
DECLARE_INTERFACE_MAP()
DECLARE_OLECREATE(CMyA)
};
// MyA.cpp : implementation file
-- -- -- --- -- --
//IMyA Functions
STDMETHODIMP_ (LONG)
CMyA::XMyAObj::MyAdd (INT x,INT y)
{
return (x+y);
}
-------------------------------
// function to be added to Interface can u please help me how to declare this function in interface.
char* getDate()
{
struct tm *newtime;
char am_pm[] = "AM";
-- - - -
--- - -- - - -
}
Thanking you,
Suresh H
|
|
|
|
|
I am programming a MFC project using Visual C++. I encountered a problem with the following code snippet.
The code snippet could be compiled successfully.However, an error occurred when running the line
<br />
free(SampleDocName); <br />
in the following code snippet, free(SampleDocName) causes error if the line
<br />
SampleDocName[ SampleDocNam_Len ] = '\0';<br />
is not used.
<br />
char * SampleDocName;<br />
int SampleDocNam_Len = m_EDITBOX_ExampleText.LineLength(0);<br />
SampleDocName = (char *) malloc(sizeof(char) * (SampleDocNam_Len+ 1 ) );<br />
m_EDITBOX_ExampleText.GetLine(0, SampleDocName );<br />
<br />
SampleDocName[ SampleDocNam_Len ] = '\0';
<br />
<br />
free(SampleDocName); <br />
I do not why. Please help me.
|
|
|
|
|
Why are you using malloc() and free() in C++ code, you should be using new and delete . Also why use the call to sizeof(char) in you malloc() call? This is pointless as the size will always be a constant 1.
Check the value of your SampleDocNam_Len and make sure no stupid values are being passed into malloc() , also make sure you are not writing past the end of the array.
|
|
|
|
|
I think you should use
GetLine( 0, SampleDocName, SampleDocNam_Len );
instead of
GetLine( 0, SampleDocName);
since for the latter you need to pass the line lenght on the first word of the buffer (MSDN):
lpszBuffer
Points to the buffer that receives a copy of the line. The first word of
the buffer must specify the maximum number of bytes that can be copied
to the buffer.
Also will be nicer if you use the C++ allocation pair new/delete
(you are free to use free of course, but as matter of style...).
|
|
|
|
|
Hi all,
Please any body tel me how to hide a tab control from the property sheet.
I tried
GetTabControl()->ShowWindow(SW_HIDE);
But when executing this all the tab control of the sheet goes to hide.
But i want to hide a single tab control.
Please tel me anybody knows it.
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
Ok..Now no need to any reply for me.
I solved it.
I tried RemovePage of Sheet.
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
Hi, do you guys know how to set(change) the short file name of a specific file inside visual c++? Is there any API doing that?
Thanks!
|
|
|
|
|
The short file name of a long named file is the first six chars, a ~ and a number, starting with 1 ( depending on how many have those 6 chars ). Not sure if it goes to 5 chars for > 9 files.
You can't set it AFAIK
Christian Graus - C++ MVP
|
|
|
|
|
I think you actually cannot.
|
|
|
|
|
If you're on XP+ and the file is on an NTFS volume, you can use SetFileShortName() .
|
|
|
|
|
Can someone give me a real, WORKING - example(code) of how to "CreateDirectory" , "CopyFile" and "ChangeDirectory" in MFC.
I know how to use these "verbs/tokens" in non-MFC programs, but they aren't available to you in MFC; because you can't "#include <window.h>" in MFC.
So how do you do the same things in MFC. Example code PLEASE!
A C++ programming language novice, but striving to learn
|
|
|
|
|
windows.h is very much included in MFC.
Here's a working sample
::CreateDirectory(_T("C:\\TESTTEST"), NULL);
HANDLE hFile = ::CreateFile(_T("C:\\TESTTEST\\test.tst"), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
::CloseHandle(hFile);
::CopyFile(_T("C:\\TESTTEST\\test.tst"), _T("C:\\test.tst"), TRUE);
::SetCurrentDirectory(_T("C:\\TESTTEST"));
|
|
|
|
|
Larry Mills Sr wrote: because you can't "#include <window.h>" in MFC.
Not true. MFC is a wrapper on Win32, you call any Win32 API you like. Sounds like you have another problem ?
Christian Graus - C++ MVP
|
|
|
|
|
Apparently <windows.h> is already included by MFC headers (AFXV_W32.H).
Regards
|
|
|
|
|
Thanks. Everyday I learn and learn and learn; but sometimes I forget what I learned.
I never realized that windows.h was included in MFC, so dumb me tried to do everything I wanted to do without using any API functions. You've just made my programming life much, much simpler,
Again thanks.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Hi all,
in my application (MFC MDI Document/View) I use a datagrid and a chart control, each of them in a static splitter pane. Now, I want to provide a different view on my data and therefor I want to open a new child with a "different" view class (derived from CFormView) while the first view is still open. The menu which is displayed should depend on the View which is currently active.
Can anybody give me a hint and show me the pitfalls?
Thank you,
Frank.
|
|
|
|
|
Hi All,
This seems such a simple problem, I am embarrassed to ask for help, but I just can't seem to get the syntax correct for the CopyFile command. My application builds a vector of CStrings containing commands in format Copyfile( "source file", "dest file", FALSE ), using double quotes around the file specifications in case there are embedded spaces. The following is one of the commands:
CopyFile( "C:\Documents and Settings\rfickling\My Documents\Expense Report Form.xls", "Expense Report Form.xls", FALSE );
All of these commands fail with an error code of 123, which indicates invalid call syntax. What is wrong here? Can anyone help me with this dumb little problem?
Thanks,
Royce
|
|
|
|
|
RoyceF wrote: CopyFile( "C:\Documents and Settings\rfickling\My Documents\Expense Report Form.xls", "Expense Report Form.xls", FALSE );
Don't you escape slashes?
|
|
|
|
|
Yes, in the CString.Format() method call you do:
CString str;<br />
str.Format( "C:\\Documents and Settings\\rfickling\\My Documents\\Expense Report Form.xls" );
I am actually formatting these file specs into CString variables so that it looks like the following:
strSrc = "C:\Documents and Settings\rfickling\My Documents\Expense Report Form.xls"; <br />
strDst = "Expense Report Form.xls"<br />
So the command in C++ syntax is:
CopyFile( strSrc, strDst, FALSE );
This should work, but I get a 123 error.
|
|
|
|
|
I think the problem is the target file name. You are giving just a filename, so Windows tries to create the file in the current directory.
And what's the current directory?
Try giving a targetname with a complete path, if possible.
Or make sure the current directory is set to where you want the file to be copied to.
SetCurrentDirectory();
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
The following code works fine on my computer (Win2k):
CString strSrc, strDst;
strSrc.Format( "C:\\Documents and Settings\\Carlo\\My Documents\\Donald Duck.txt" );
strDst.Format( "Donald Duck.txt" );
if ( CopyFile( strSrc, strDst, FALSE )==FALSE)
{
}
|
|
|
|
|
Error code 123 is "The filename, directory name, or volume label syntax is incorrect."
Does this help narrow it down?
*EDIT* You shouldn't have to add any double quotes because of spaces.
-- modified at 18:10 Wednesday 22nd November, 2006
|
|
|
|
|
RoyceF wrote: CopyFile(
instead of this use ShFileOperation
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|