|
Hy, since I'm new to MFC/C++ programming, I could really appreciate some help.
So can someone please explain to me what function should I use if I wanted to change the color of the dynamic (input) text that user enters? The user should be able to select the color he wants.
Thanks
Alessandra
|
|
|
|
|
You can add a WM_CTLCOLOR handler to your window/dialog class and in your handler method, use
SetTextColor() to set the color for edit control(s). The background color can also be set.
Something like this:
HBRUSH CMyWnd::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CWnd::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor == CTLCOLOR_EDIT)
{
pDC->SetTextColor(RGB(0x00,0xFF,0x00));
}
return hbr;
}
To let the user pick a color you could use the color-picker common dialog (the MFC CColorDialog
class wraps it). Store the COLORREF picked by the user and use it in place of the
"RGB(0x00,0xFF,0x00)" in the code above.
Mark
|
|
|
|
|
Thanks
Alessandra
|
|
|
|
|
can someone help in some way i could monitor un EXE stack and read the respective handles like in real time to try to find out what is going on in the stack and what is happening in the handle system...
its a uni work to detect if un exe was changed or not, i detected a strange handle that apears with diferent names but some information is the same, but the memory where the handle is located it changes each time i run the 2nd prog that changes the 1st prog..
someone could help me with a doc to write a smal thing in c++ to read in real time in way to monitor a exe stack and handles..
someone could help what means size of a handle: 0x0001e000 (???) in size this is what ?
|
|
|
|
|
no one ???
|
|
|
|
|
I'm not sure what you want to look at on the stack. automatic variables? Return pointers?
That's all that's there that is useful info. If you use the disassembly window while debugging
you can see how compiled code is manipulating the stack. My assembly skills are too rusty to
provide any sample code
What kind of handles are you referring to? Operating system handles like HWND, HANDLE, etc.?
OS handles in Windows are opaque - they have no meaning to the user except that they represent
some object in the system. You can't, as a programmer, make any assumptions about the type
or contents of a handle. A handle could be a simple value, a structure, a pointer to a structure,
an index, etc.
You asked about the size of a handle. What do you need to know? The size of a HANDLE object?
Mark
|
|
|
|
|
thanks for your reply..
what i mean to read in the handle, is sections is the most important, and then mutant, file and events..
about the stack, i need to know the stack information about a thread thats is running with the EXE. for example a thread stack:
ntkrnlpa.exe!KiUnexpectedInterrupt+0xf0
win32k.sys+0x2fa0
win32k.sys+0x37a6
win32k.sys+0x37c3
ntdll.dll!KiFastSystemCallRet
firefox.exe!JVM_GetJSSecurityContext+0x2d9e6
firefox.exe+0x1012
kernel32.dll!RegisterWaitForInputIdle+0x49
i need to monitor the stack of this thread in way to monitor...
when i mean about the size of 0x0001e000 is that because i dont know what means all that number "0x0001e000" i dont have a clue...
thanks for the help would be apreciate, im looking more for a tuturial that could explain how to work with threads and handles read this kind of information from a file
|
|
|
|
|
I'm not sure about the stack stuff, but handles I can help with.
van-ux wrote: when i mean about the size of 0x0001e000 is that because i dont know what means all that number "0x0001e000" i dont have a clue...
My previous point was that it's not for you to know. It's not documented and Microsoft can choose
to change what it represents at any time. You may find some documentation online about certain
Windows handles but it's really not useful - it can change at any time.
"0x0001e000" is probably an address...but maybe it's an index. Maybe it's bit flags.
Handles and Objects[^]
DLLs, Processes, and Threads[^]
|
|
|
|
|
thanks for the links m8, i have a look, and i have something to read now thanks
btw i saw that handles are contained inside the objects, and the objects contain all information about the handles asuel... you know a good tuturial or book that could help me in this case just by chance, otherwise i will google it...
the book i mean for programming...
thanks great post
|
|
|
|
|
van-ux wrote: you know a good tuturial or book that could help me in this case just by chance, otherwise i will google it...
I don't know of any specific titles offhand, sorry
|
|
|
|
|
I am trying to change font size in an edit box with the following code. There seems to be a limit on the size I can get, regardless of the params in font.CreatePointFont . The max seems to be about 14 point bold. How can I get a larger size?
CFont font;<br />
font.CreatePointFont(920, "Garamond");<br />
CFont *pFont = (&font);<br />
GetDlgItem(IDC_EDIT_Utility)-> SetFont(pFont, TRUE);
|
|
|
|
|
How are you checking to see if you get the requested size?
You could try checking the created font to see the attributes of the created font:
CFont font;
font.CreatePointFont(920, "Garamond");
LOGFONT logfont;
font.GetLogFont(&logfont);
Is that the way you've coded to create the font? If so, if "font" goes out of scope then the
fonts handle (HFONT) is destroyed.
Mark
|
|
|
|
|
Hi,
I have created a SDI with FormView. The data from the view can be stored into a file and when the file is clicked, it opens directly into the formview with the edit boxes automatically filled.
Now, when one file/document is open, if the user selects File-New from the menu, a new document opens and all the fields on the Form get reset (set to zero). The previously open document gets closed.
I would like to ask the user if he would like to save the data before opening a new document.
I have put this option when the Exit button is clicked, but am not able to figure out how to open a new document after the saving process is over.
Please help!
Fortitudine Vincimus!
|
|
|
|
|
Override CDocument::OnCloseDocument().
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
AH!! This works ... Is it the correct way?
I added this in the MainFrame Class:
void CMainFrame::OnFileNew()
{
CSFPAView *pFV = (CSFPAView *)GetActiveView();
if (pFV->DoBeforeExit())
{
CSingleDocTemplate * pTemplate = (CSingleDocTemplate *) GetActiveDocument()->GetDocTemplate();
pTemplate->OpenDocumentFile(NULL);
}
}
Fortitudine Vincimus!
|
|
|
|
|
Tara14 wrote: I would like to ask the user if he would like to save the data before opening a new document.
If the document contents have not changed, no prompt is necessary. Otherwise, look at the SetModifiedFlag() method.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello everybody. Recently I coded a client-server application and put it in the start up folder. Everything works perfect except for the log file. The problem is this: When the computer starts up the log file opens fine according to file.is_open(), however, nothing gets written to the file. This only happens on start up. If I open it myself the log file works fine and records everything. But when placed in the startup folder to open itself it fails??? What could be the problem?? This has been annoying me forever and any help would be appreciated. Thanks in advance everybody!!
by the way: using windows XP, VC++ 7
-- modified at 16:01 Tuesday 6th February, 2007
|
|
|
|
|
Are you using the complete path or a relative path when specifying the name of the log file when you open it?
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
|
Try using an absolute path instead.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thank you very much works fine now
|
|
|
|
|
Hi,
I am running visual C++ 6.0 MFC. I need to have a secondary thread marshal an interface pointer using CoMarshalInterThreadInterfaceInStream(REFIID riid, LPUNKNOWN pUnk, LPSTREAM* pStm); The interface is used to automate Excel. I want my primary thread to access the interface using CoGetInterfaceAndReleaseStream(LPSTREAM pStm, REFIID riid, LPVOID* ppv); What I need to know is how do I find riid, the reference to the identifier of the interface to be marshaled?
Thanks,
Buck
|
|
|
|
|
AFAIK the REFIID is declared in the header file for the object you are using. I am not familiar in automating Excel but I know there are several articles here on CP that cover the subject. Do a search.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
I have been searching the web for 6 hours and all I can find are references to CoMarshalInterThreadInterfaceStream() and CoGetInterfaceAndReleaseStream() but I cannot find ANY real examples. Where does the COM interface store this REFIID? I need to find out how to get the REFIID so I can pass it into these two functions.
Buck
|
|
|
|
|
If you've #import ed the typelib then you can add the import directive named_guids to the import statement.
Then you will find the IID in the .tlh file.
Otherwise you could marshal the IDispatch interface, unless you're using the v-table part of Excel's dual interfaces. Just use IID_IDispatch as REFIID .
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|