|
If you read the MSDN documentation for either class's read method you will find: the return value may be less than nCount if the end of file was reached
--
Pictures[^] from my Japan trip.
|
|
|
|
|
SeekToEnd
will make the file pointer at the end of file data
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
CFile::Seek( 0L, CFile::end ) same SeekToEnd
|
|
|
|
|
Hello,
I am trying to play video inside a panel.
The problem is that i can't get a window handle for the planel and here is the code that i am wriiting:
pWindow->put_Owner (this->panel1->Handle);
[Error C2664]: 'IVideoWindow::put_Owner' : cannot convert parameter 1 from 'System::IntPtr' to 'OAHWND'
How can i fix this problem. My end goal is just to play the file in the panel not in a pop up window!!
Thanks
|
|
|
|
|
try out with this
pWindow->put_Owner ((OAHWND)this->panel1->Handle);
and tell me again...
Kifayatulah
CDigital Islamabad
Tel.03215309934
|
|
|
|
|
I want to learn how to use the Boost libraries for regular expressions. Can anyone give me a step by step on how to get RegEx and implement it into an MFC app? I would like to be able to search for string patterns in text document displayed in a CEditView or CRichEditView. Thanks.
Mark
|
|
|
|
|
|
Thanks. I somehow missed this.
Mark
|
|
|
|
|
I am trying to paste an information icon into my mfc project.
I found in internet that the way to do it would be something
like this:
BOOL MyAppDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CWinApp* pApp = AfxGetApp();
CDC* pDC = GetDC();
HICON hIcon;
if( pApp != 0 )
{
hIcon = pApp->LoadStandardIcon(IDI_INFORMATION);
bool b = pDC->DrawIcon( 20,230, hIcon );
}
ReleaseDC(pDC);
DestroyIcon( hIcon );
}
This is not working for me, the icon is not being drawn. So I changed this and
put it in a button event. So now when I press a button the icon is being drawn.
Why doesnt this work in OnInitDialog() ??
My other problem is that when my window goes into the background the icon disappears.
How should I draw the icon to be static in the gui?? Actually I would prefer to
paste it like a button or edit box instead to do it with code..Is there a way to do
this?
Thanks.
|
|
|
|
|
I think the icon doesn't work in OnInitDialog because the dialog is painted again, so the icon disappears very quickly.
You can put the icon-drawing code in OnPaint() .
OnPaint()<br />
if (IsIconic())<br />
{<br />
}<br />
else<br />
{<br />
CPaintDC dc(this);<br />
HICON hi = AfxGetApp()->LoadStandardIcon(MAKEINTRESOURCE(IDI_INFORMATION));<br />
dc.DrawIcon(10,10,hi);<br />
CDialog::OnPaint();<br />
}
About your last question, if you want a static icon on the dialog, you can put a picture control on it, and set the property: "type" to "Icon" and the "Image" to whatever icon you have in the project.
this is this.
|
|
|
|
|
|
hi,
I have wrote the code for excel addin using xlsdk in VC++ MFC. The call to DoModal fails in VC++ 7.0 but works fine with VC++ 6.0.
Code given below
__declspec(dllexport) xlAutoOpen()
{
//... piece of code
CControlPane dlg;
dlg.DoModal; //Fails in VC 7.0 but works fine with VC 6.0
}
mayank.jindal@mphasis.com
|
|
|
|
|
I've created many tables in a SQL Database. I'am using Ole Db to open its. Every tables except one I can open with the Propety DBPROP_IMMOBILEROWS in true mode, but only one of this tables can't open that way, the Prob must be false, why?, Any Suggestion? thanks....
propset.AddProperty(DBPROP_IMMOBILEROWS, false); propSet must be false, other way I have Open Error....
|
|
|
|
|
I have a inproc dll component and MFC Client. I wrote a mc file containing my user defined HRESULT. I am returning the custom HRESULT from the component in the following way:
<br />
if(SUCCEEDED(hr))<br />
{<br />
return E_FILESAVED;<br />
}<br />
where E_FILESAVED is my custom HRESULT.
In my client I use the following :
<br />
void* pMsgBuf;<br />
HANDLE ghResDll;<br />
char lpMsgBuf[BUFSIZE];
<br />
<br />
ghResDll = GetModuleHandle(NULL);<br />
DWORD dw = GetLastError(); <br />
CHAR szBuf[80]; <br />
sprintf(szBuf,"%u",dw);<br />
<br />
AfxMessageBox((LPTSTR)szBuf,MB_OK,0);<br />
::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_FROM_HMODULE,<br />
ghResDll,hr,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),<br />
(LPTSTR) &lpMsgBuf,BUFSIZE,NULL);<br />
AfxMessageBox((LPTSTR)lpMsgBuf,MB_OK,0);<br />
I see the correct hr (value) being returned in the client after my function in the component returns but the string is a null string.
Can anyone help me with this? Thanks in advance..
-Mandira
|
|
|
|
|
First, void* pMsgBuf; has been declared but not used. I think you should use pMsgBuf instead of the lpMsgBuf[BUFSIZE]; because the flag: FORMAT_MESSAGE_ALLOCATE_BUFFER causes memory to be allocated to the buffer, which you should deallocate using LocalFree(...);
And use FORMAT_MESSAGE_FROM_SYSTEM instead of FORMAT_MESSAGE_FROM_HMODULE .
Hope that helps.
this is this.
|
|
|
|
|
Hi,
Thanks for the reply. I had a LPVOID lpMsgBuf declared which i was using (not seen in posted code).
The reason I have used FORMAT_MESSAGE_FROM_HMODULE is because I have my own custom HRESULT codes defined in the mc (message compiler file) and their corresponding messages.
FORMAT_MESSAGE_FROM_SYSTEM only displays the system defined messages ..
and E_FILESAVED is a custom-defined message defined in mc file as follows:
<br />
MessageId = 2000<br />
SymbolicName = E_FILESAVED<br />
Language = English<br />
File Saved Successfully!<br />
Thanks!
-Mandira
|
|
|
|
|
You can take the contents of the newly-created .RC file, and place them in the .RC2 file for example. That should help. If you don't have a .RC2 file, then place the text directly in the .RC file.
this is this.
|
|
|
|
|
In the description of SetWindowText(), it states that "it cannot change the text of a control in another application". Does anyone know how to do this, given the handle of the window control ? Thanks (in advance !!)
Doug
|
|
|
|
|
It shouldn't be possible to write to another application's textbox because your text buffer is located in your program's address space, not their's .
You can check the following article:
http://www.codeproject.com/threads/winspy.asp[^]
There are other articles as well.
this is this.
|
|
|
|
|
Thanks Khan++ for your reply,
The article that you referenced is going to take "some reading" !! I DO hope that there is some way to write to another app's controls as otherwise my current idea is "stuffed" !!!
Any other replies/suggestions to my problem would be welcomed !!
Doug
|
|
|
|
|
As per SetWindowText documentation:-
"To set the text of a control in another process, send the WM_SETTEXT message directly instead of calling SetWindowText"
Vipin - MVP
|
|
|
|
|
Hi Vipin,
I use VC++ Ver 6.0 and can't see this statement in SetWindowText(). What version do you see it in ?
Doug
-- modified at 17:10 Monday 26th December, 2005
Just checked MSDN and I DO see that statement - why doesn't 6.0 include it ??
Anyhow, great relief, as the other possibilities are pretty complex !! Thanks everyone !
|
|
|
|
|
Hi I have a problem.....
Actually i wrote a code which runs in service and hides in tray icon when minimized or closed...
When iam testing it by executing, its working , after when i restart the system to make run in service..
It is visible in service ,But No tray icon is Visible
If i keep any message Box in OnCreate() function ,
Then it's Working ...
Please help me...............
Thanks in Advance
|
|
|
|
|
I think it is because the service runs before any user is logged-on to the system, so when the serivice is setting its icon, the system tray has not been spawned yet.
I would suggest that you reset the tray icon every minute or so, so that it can be seen. Also, if explorer.exe crashes, all icons disappear. If you reset your icon every minute or so, your icon will remain in the tray.
this is this.
|
|
|
|
|
Try making the service Interactive service.
Vipin - MVP
|
|
|
|