|
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
|
|
|
|
|
vipinasda wrote: Interactive service.
Happy christmas friends. May the Love of My Lord and Saviour Jesus bring forth Joy and Happiness into your life too.
<marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" hspace="2" vspace="2">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Owner drawn wrote: vipinasda wrote:
Interactive service.
I believe he is right in his comment
"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
|
|
|
|
|
Actually, I used a class from here in my BugReporter[^]app to aid in putting the icon in the system tray. That worked great! But I also got the problem that when Explorer crashed and came back up, my icon was no longer in the tray. I can't remember off the top of my head, but you can register a message that will notify you of when the system tray/taskbar is being re-instantiated or redrawn. Handle that message and then redraw your icon. I think that's better than checking every minute. If you'd like to look in the BugReporter project, I think it's in the CMainFrame class that I did this.
My articles
BlackDice
|
|
|
|
|
jakib wrote: Please help me...............
For that you have to create Desktop interactive service.. you have to do that by two way :-
Manual Way:-
Right Click on Service-> Choose Properties menu item-> then when Property Sheet get displayed-> choose Log On Tab-> check Allow Service to interact with Desktop check box.
Coding Way:-
while installing service using CreateService api pass SERVICE_INTERACTIVE_PROCESS as one of parameter
"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
|
|
|
|
|
Hi
i need to write a control that has to be plugged into unmanaged as well as managed UI applications,...
Control Description:
the control is going to be like supporting browsing and searching objects etc,..control have to have mostly UI stff in it(will have some buttons/edit boxes trees and list boxes inside it)....that will have to adjust its controls according to its container,..should support drag and drop from control to the application plugged into that can be managed or unmanaged application...
so should i make an ActiveX control or .Net Windows Control, ?
would like to have your comments on it,..backed up with pros and cons...etc..
Thanks all
Muhammad Ahmed
Ahmed
|
|
|
|