|
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..
|
|
|
|
|
One issue that immediately comes to mind is the concept of obfuscating the credentials. It's very tempting to attempt IT chores such as changing HKCU registry changes, changing priviledges for user/groups, etc...
However, simply right clicking on the exe and opening with Notepad allows a user to scroll down to where your string literals all get bunched together, and where all that plain text sticks out like a sore thunb amongst all that binary crud and low and behold, there's the admin's password staring back at you. Anytime a sensitive password is one shell action away from every Joe Blow on the network, (This password obviously is the same for more than one box or you wouldn't go through all this trouble to automate the action) I tend to cringe.
You can choose to obfuscate the string literal using and encryption library but the key still needs to be stored in a literal. You could create a function that generates some string and decrypt your string literals as you use them which would eliminate any unencrypted strings be stored in the exe. This only abstracts the sensitive data but since you don't know who will get a copy of this exe as it is deployed, any determined and capable person could disassemble and trace through the code to determine the key produced by the function. How important is it to you to protect your network, machines, data, company, job?
Anyway, I'm just trying to give you a friendly sober second thought to consider at least obfuscating your credentials in the exe at a minimum instead of making it easy for the power users to see those credentials.
|
|
|
|
|
credentials are already hidden in the code via an encryption/decryption routine run during runtime
Thanks for the heads up though
|
|
|
|
|
i got a file.txt:
Test1 < - 1rst line
Test2
How i put a string:
CString TString = "How I write text in files";
in the file (but each line hold 10 chars so the file.txt would be):
Test1 <-1rst line
Test2
How I writ (10 chars)
e text in (10 chars)
files
|
|
|
|
|
CString sFilePath="your path/filename go here";
CStdioFile file;
CString sOutput="How I writ (10 chars)\r\ne text in (10 chars)\r\nfiles";
try {
if (file.Open(sFilePath,CFile::modeReadWrite|CFile::modeNoTruncate)) {
file.SeekToEnd(); // Go to end of file.
file.WriteString(sOutput); // Append text
file.Close();
}
}
catch (CException * e) {
e->ReportError(); // Popup description of exception
e->Delete(); // Clean up.
}
catch (...) { // Catch any other exceptions
AfxMessageBox("Failed to open file!");
}
-- modified at 12:32 Sunday 28th May, 2006
|
|
|
|
|
Thx i am going to try this.
But the CString sOutput it would have random char lenght
(so i have to GetLength(); )
int m_Count = sOutput.GetLenght();
int m_Edit = m_Count / 10 // = How many lines i need
if ( m_Edit%10 != 0)
{
m_Edit = m_Edit +1;
}
Now to edit the the sOutput in the form i want :
for ( m_Edit >= 1 ;m_Edit-- )
sOutput.SetAt(m_Edit*10)="\\n";
SetAt is the right command to add the \n in the string?
-- modified at 12:50 Sunday 28th May, 2006
|
|
|
|
|
Your making it harder than it should be. (NOTE: the appending to existing file thing was an assumption so if your wanting to create the file new each time if it doesn't exist and overwrite the previous file if any, use the modified open flags below)
CString sFilePath="c:\\temp\\myfile.txt";
CStdioFile file;
CString sOutput="This is a long string to see how to append every 10 chars in the string to a file";
int nCount=sOutput.GetLength();
try {
if (file.Open(sFilePath,CFile::modeReadWrite|CFile::modeCreate)) {
file.SeekToEnd(); // Go to end of file.
for (int i=0;i<nCount;i+=10) {
file.WriteString(sOutput.Mid(i,10)+"\r\n"); // Append text
}
file.Close();
}
}
catch (CException * e) {
e->ReportError(); // Popup description of exception
e->Delete(); // Clean up.
}
catch (...) { // Catch any other exceptions
AfxMessageBox("Failed to open file!");
}
-- modified at 13:35 Sunday 28th May, 2006
|
|
|
|
|
Also, a word of caution concerning the \n.
newlines can be \n or \r\n in text files but when outputting your results to an edit control, you will need the \r\n pair. Not that it matters but in case you start dumping your text output to a GUI I thought I'd give you a heads up since your just using a newline in your snippets.
For what it's worth...
|
|
|
|
|
thx
|
|
|
|
|
Hi,
I'm new in Visual C++ .net 2005 and I'm writing a Newsreader and i have the following problem:
on my form load event i'm reading a text file into my listview, the textfile contains about 66000 lines, so when the form loads it doesn't respond for a few seconds. I have already searched the new for an answer to my question but nothing could help me out...it also tried to use the virutal mode for the listview but I don't get on with this mode
I'm becoming desperate...so it would be very nice if someone could help me on this, maybe sending me a tutorial or a very simple sample code
thx in advance
No need to invent new thing when they already exist
|
|
|
|
|
Master Gollom wrote: textfile contains about 66000 lines
I think I know why it's taking so long to load the listview.;P
|
|
|
|
|
I also know that the 66000 lines are taking much time but there must be a way to load them faster
|
|
|
|
|
make 11 threads which load 6000 lines ? (isnt that be 11 times faster )
|
|
|
|
|
|
thanks for your answer, but i have already found this link on the net but it couldn't help me out because this code is not in vc++ .net 2005
|
|
|
|
|
I need to have a control like CDragListBox (I need dragging), but it should also have a check box and a small bitmap for each item. Is it posible (and quite easy) to add check box and bitmap to CDragListBox control?
Or should I rather use CListCtrl? What's easier to implement?
Can you give me some advice please? And by the way some samples if you have any.
~~~~
|
|
|
|