|
Hmm. I never noticed that before but you are right.
Somebody posted this link elsewhere in CP about a bug. I'm not sure if it'll help you but here's the link...
From FredBloggsy[^]
-- modified at 17:47 Sunday 28th May, 2006
By the way, I was on VC++ 6.0 when I reproduced it so it seems it's in all versions. It does seem to be a "reasonable" limit for the most part.
|
|
|
|
|
CString Test = "Remove the word TEST"
how i remove the TEST ?
so i gonna have
CString Test = "Remove the word "
|
|
|
|
|
CString sData="Remove the word TEST";
CString sWord="TEST";
int nIndex=sData.Find(sWord,0);
if (nIndex!=(-1)) { // Found it
sData.Delete(nIndex,sWord.GetLength());
}
TRACE("%s",sData);
|
|
|
|
|
thank you very much bob16972 you helped me much today
|
|
|
|
|
Another method is :
CString Test = "Remove the word TEST";
Test.Replace("TEST","");
|
|
|
|
|
That'll remove every instance of the word "TEST". The other will remove the first instance only.
Just a heads up for the sake of clarity.
For what it's worth...
|
|
|
|
|
yes that is true, btw what she/he wanted exactly ?
|
|
|
|
|
Honestly I'm not sure at this point. You were right in posting your stuff. I wasn't jumping on it. I just threw in the clarification for they're benefit so they knew the implications of each method.
Sorry if I approached that wrong. It never dawned on me that the user might want all instances removed so I'm glad you caught that.
Thanks and take care.
|
|
|
|
|
bob16972 wrote: That'll remove every instance of the word "TEST". The other will remove the first instance only
In that case how will he/she determine which TEST keyword he have to removed
"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
|
|
|
|
|
Hi All,
I have a formview app with a propertypage imbeded in a nother property page.
How do I link this to a menu?
Any help would be greatly apreciated.
Ferdinand
|
|
|
|
|
A formview app should have a menu already. Are you asking how to make menu items do something in your formview?
If you could provide a little more detail describing the problem and context, I would be less reluctant to post a suggestion.
Thanks
|
|
|
|
|
Yea, I'm trying to link menu items provided by the app wizard to dynamic property page within a property page.
|
|
|
|
|
Ok, it's been a while since I messed with these but I found an app and got my trusty old Jeff Prosise book out and the rust is started to give a little.
Forgive me if I'm off a little at first but you say "menu items provided by the app wizard". Are you using VC++ 6.0 or VC++ 2003 or VC++ 2005? I'm thinking your referring to the MFC wizard DDX/DDV stuff but I afraid to go that route without confirmation.
I'm thinking of a dialog resource that needs it's fields "bound" to member variables for the Propert Page class. Let me know if I'm on or off target here.
|
|
|
|
|
Hi Bob,
First, Thanks for the help.
I'm using VC++ 6.0. When I use the app wizard, It places the command handlers in the correct class, but the menu items are still greyed out.
|
|
|
|
|
Is this what your looking for?
void CYourFormView::OnUpdateSomeMenuItem(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here
if (Some expression that resolves to TRUE if menu should be enabled)
pCmdUI->Enable(TRUE); // Enable the menu item
else
pCmdUI->Enable(FALSE); // Disable the menu item
}
-- modified at 1:38 Monday 29th May, 2006
|
|
|
|
|
Actually, I was looking for something more like this.
IMPLEMENT_DYNCREATE(CMYView, CFormView)
BEGIN_MESSAGE_MAP(CMYView, CFormView)
ON_WM_SIZE()
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_SAVEAS_TEXT, OnSaveasText)
N_UPDATE_COMMAND_UI(ID_SAVEAS_TEXT, OnUpdateSaveasText)
END_MESSAGE_MAP()
If placed in the view class everything works fine. However, if this is placed in an embeded class, I don't recieve the messages in that class. and nothing happen.
|
|
|
|
|
unfortunately I cannot see a way to make that work. At least not directly.
I googled and found some articles relating to ON_UPDATE_COMMAND_UI and dialogs. WM_KICKIDLE gets tossed around quite a bit in those articles but it's somewhat over my head I think.
I'm leaning toward the CFormView ON_UPDATE_COMMAND_UI handler since it can see the PropertySheet/Pages public info. Any decisions that influence the results of the ON_UPDATE_COMMAND_UI you planned in the PropertySheet/Pages could still be performed in the CFormView.
Sorry that I wasn't able to provide any help on the matter. I did piece a FormView app like you described and tried brute forcing it but it seems much more complex than I anticipated.
Good luck in your efforts.
|
|
|
|
|
Thanks anyway,
I didn't find anything useful on the net either.
I think I'll just handle the message in view class and call the page functions from there.
Thanks again.
|
|
|
|
|
I got 4 dialog in my application
Which is the command for Destroy a dialog?
There is command so i can use both ,child and parent ,dialog ?(or it needs a thread ?)
|
|
|
|
|
|
hm?
I have a MFC project with 1 parent CTestDlg (with his CTestApp)
i have create 3 Form Class (CTest1Dlg, CTest2Dlg, CTest3Dlg)
CTest1Dlg and CTest2Dlg are Children of CTestDlg
CTest3Dlg is child of CTest1Dlg
What i have to put in the CTest1Dlg::OnNewWindowButton()
so i can view + act on both CTest1Dlg and CTest3Dlg ?(or i cant?)
|
|
|
|
|
That would require modeless dialog boxes which are usually instanciated on the heap and using them easily becomes confusing, time-consuming and error prone since the dialog usually is responsible for deleting itself but all the while someone else has a pointer to it so SendMessage becomes a necessity to communicate what is happening to the main window.
void CYourView::OnShow()
{
// TODO: Add your control notification handler code here
if (m_pDlg) // Window already exists so go to it
m_pDlg->SetFocus();
else {
m_pDlg=new CYourModelessDlg();
m_pDlg->Create(IDD_MODELESS);
m_pDlg->ShowWindow(SW_SHOW);
}
}
void CyourModelessDlg::PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class
CDialog::PostNcDestroy();
delete this;
}
void CYourModelessDlg::OnCancel()
{
// TODO: Add extra cleanup here
DestroyWindow();
// CDialog::OnCancel();
}
Obviously, there are quite a few "gotchas" here that I won't even bother to get into as well as the extra work required to communicate between the dialog and the main window. This is where I'll suggest you consider using property sheets/pages or at least try to combine the functionality into a single stack based modal dialog. This way, everything fits well into a single function since the DoModal command blocks and there is no concern for resource cleanup since the dialog instance is usually local. There's no need to communicate when, where, and how the dialog was dismissed as your return variable has all that and getting your data is a breeze since the dialog does not go out of scope until the function ends. Need I mention that there is no dangling pointer as you probably noticed the modeless dialog leaves this particular dangerous situation for you to sort out on your own.
For what it's worth...
|
|
|
|
|
Hey folks:
I have some questions about XML/Soap/HTTP... but first, requirements!
0) Open a socket to a server
1) Receive XML data from a server
1.5) Close that socket
2) Parse through the XML file
3) Download all associated web content for each given URI in the XML file
4) Open a socket to the server
5) Send an XML file back to the server
6) Server will process this, and should send back a response, whether the update was successful - or not.
7) I need to prevent malicious users from trying to update *other people's accounts*... i.e. the user should *only* be able to update dta bsed on their own userId, but not an arbitrary user id.
8) MFC can be used, if it makes it any easier... no .NET however.
Questions:
1) As far as sending/receiving XML files from from a server, have I missed any steps?
2) Do I need to do anything with SOAP here? What would the advantage of using SOAP be?
3) How do I prevent malicious users from updating other people's acccounts?
4) How should I approach the socket issue?
5) How can I make the socket opening work *no matter* which firewall you have, or *no matter which router* you use?
6) The data I'm sending is all web content, so can I use a special port on the Windows side that says that all Internet traffic is OK?
7) I only want the user to have to approve my applicaation's ability to access the Internet, once. How can I ensure they don't have to continue to grant exceptions via their firewall?
8) Is there a way of grabbing a free port from Windows?
9) Is there a way of *reserving* a specific port on Windows so that no other appliction will be able to use it? (I'm afraid another app might steal my port, or that it would be occupying the port when my app needs to use it).
Help your local n00bie! :P
Responses/how-tos/articles/guides/links/explanations would all be useful.
Please phrase your response something a n00bie can understand.
Thanks very much for your help in advance?
-chasetoys
|
|
|
|
|
Overview:
I'm trying to write a util that will allow users in the local 'Power Users' security group the ability to add/remove their access to regedit, .cpl entries, mmc, etc. Unfortunately, Power Users don't (by default) have access to make changes to hkcu\software\microsoft\windows\currentversion\policies (where these registry keys need to be created/modified)
By calling CreateProcessWithLogonW (passed local Administrator credentials) with a NULL parameter for the dwLogonFlags parameter, I thought it wouldn't perform a LOGON_WITH_PROFILE -- but it does anyway. This causes the Power Users HKCU hive to be overwritten with that of the local Administrator.
So, currently my plan is to have two processes:
a.exe: Runs CreateProcessWithLogonW to call process b.exe (which will run as local administrator):
b.exe runs NetLocalGroupAddMembers to add NT AUTHORITY\Authenticated Users to the local Administrators group , thereby giving them access to make changes to the registry key above. control returned to caller (a)
a.exe: Make registry key changes to HKCU hive of the Power User. Changes are complete. Remove user from Local Security Group (don't need admin rights for this)
Summary:
As you can see, to perform this task I need two executables. Seems a bit silly (and there's probably an easier way to do all this). Any way to combine everything into one file? Don't suppose there's some way to use run my code snippet/function for NetLocalGroupAddMembers using elevated privileges without creating an entirely new execuable for that?
Thanks for any help
|
|
|
|
|
Sorry to reply to my own thread before anyone replied, but I thought of something and just wanted some input regarding whether its good / bad / other:
process b.exe described above will be created & deleted during runtime of process 'a'
the way i'll do this is by storing and writing a binary array, etc. to a file and saving it as b.exe, then I'll execute b.exe with CreateProcessWithLogonW
Next, b.exe will be deleted (from a.exe) once its execution completes
Its a messy solution but certainly doable right?
Thanks..
|
|
|
|