|
Hi All,
I am trying to disable the minimize & maximize button in a dialog based application. The close button get's disable, but the other two are not disabled. The code i am using is
CMenu* pSM = GetSystemMenu(FALSE);
if(pSM)
{
pSM->EnableMenuItem(SC_CLOSE, MF_GRAYED |MF_BYCOMMAND|MF_DISABLED);
pSM->EnableMenuItem(SC_MAXIMIZE, MF_GRAYED |MF_BYCOMMAND|MF_DISABLED);
pSM->EnableMenuItem(SC_MINIMIZE, MF_GRAYED |MF_BYCOMMAND|MF_DISABLED);
}
i am adding this code on OnInitDialog.
Thanx in Advance
Sujan
|
|
|
|
|
Can you not just remove the WS_MINIMIZEBOX and WS_MAXIMIZEBOX styles from the dialog template?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I have a list control in report view mode.
I'm trying to highlight rows based on what info they have.
Highlighted ones have the text color set to red, non-highlighted gets black.
What I have (pseudocode) is this:
<br />
for (int i = 0; i<numEntries; i++) {<br />
color = function_to_check_info_and_return_COLORREF(info);<br />
myList.SetTextColor(color);<br />
myList.InsertItem(etc);<br />
myList.SetItemText(blah, 1, value);<br />
.<br />
.<br />
.<br />
myList.SetItemText(blah, 5, value);<br />
}<br />
Assume my function to get the COLORREF works as planned (it does, it's been checked by 2 other software engineers. They have no idea why this won't work either).
Would you agree that bit of code should set the text color for each row in the report based on the return value of the COLORREF function?
Well, it doesn't.
What actually happens is that all the items are added to the list, and then MFC applies the last returned COLORREF to all items in the list. What?!
I had the app open on one monitor while stepping through it on the other, and the list control only shows the items once they've all been added.
HOWEVER, the scrollbar appears and resizes as each item is added. So while the list is populating, the scrollbar reflects what should be in it, but it has no contents. Bizzare.
To try and force it to update as it should, I added:
<br />
myList.SetRedraw(TRUE);<br />
myList.Invalidate(TRUE);<br />
Here is a direct quote from MSDN as to what SetRedraw does:
Updating a control or window with large amounts of data may cause flicker. In such cases it may be better to turn off drawing. While the redraw flag is cleared, the contents will not be updated after each change and will not be repainted until the redraw flag is set.
In other words, setting the redraw flag to true should mean the list control updates each time something is inserted. Not so. It appears both of those statements are simply ignored.
Only once have I been able to get it to do what I want, under very specific conditions. If:
* I call myList.SetColumnWidth(someCol, LVSCW_AUTOSIZE);
and
* The data width in someCol requires the column to be resized
THEN it will work.
Obviously this is useless, as it requires each entry in someCol to be longer than the last in order to get the desired effect.
Just to prove to myself I wasn't going mad and that you CAN use settextcolor for individual entries in the list, I added a button which, when clicked, inserts an item into the list in green. It works fine (and the rest of the list stays in the color it was).
So, in conclusion:
What's going on? Am I trying to make it do something it can't or what?
I have spent all morning looking at this thing, tracing, stepping, setting breakpoints, setting watch variables, and its ABSOLUTELY FINE in terms of program flow.
Everything gets set when it should be set.
Everything is called in the correct order.
Either I've misunderstoon the purpose/functionality of settextcolor or MFC has decided to set the color when it feels like it, not when I ask it to.
If anyone has any ideas I'll be very grateful!
|
|
|
|
|
m_dale wrote:
Would you agree that bit of code should set the text color for each row in the report based on the return value of the COLORREF function?
Well..no! The SetTextColor() / SetBkColor() functions applies to the entire control, not just to an individual item within.
If you require individual control over the color and/or fonts used by row and column then have a look at Custom Drawing techniques. This[^] is a good starting article.
m_dale wrote:
Just to prove to myself I wasn't going mad and that you CAN use settextcolor for individual entries in the list, I added a button which, when clicked, inserts an item into the list in green. It works fine (and the rest of the list stays in the color it was).
Beats me This should not happen, but see below:
m_dale wrote:
I had the app open on one monitor while stepping through it on the other, and the list control only shows the items once they've all been added.
Makes sense as the drawing routine would not have been called while tracing through your code.
m_dale wrote:
In other words, setting the redraw flag to true should mean the list control updates each time something is inserted. Not so. It appears both of those statements are simply ignored.
Although I cannot be sure, I would guess that while you are in debugging mode, the usual process of pumping and processing the usual windows messages (that are responsible for your control window updates), are in stasis; therefore you cannot expect normal window actions to be performed while this is happening.
m_dale wrote:
Only once have I been able to get it to do what I want, under very specific conditions. If:
* I call myList.SetColumnWidth(someCol, LVSCW_AUTOSIZE);
and
* The data width in someCol requires the column to be resized
THEN it will work.
Obviously this is useless, as it requires each entry in someCol to be longer than the last in order to get the desired effect.
As I said above, once the window has been allowed to process its usual messages, then you will get the results you expect, but while tracing through your frozen program, one line at a time, this is expected.
I Dream of Absolute Zero
|
|
|
|
|
Ah, looks like i was being stupid.
When I drag another window over my funky multicolored list it redraws in the last color selected.
Custom drawing here I come...
|
|
|
|
|
Hello everybody, I'am a beginner using GDI+ and I want to know how to draw a gray level image, having only de size of the image and an array with the gray values of the image
thanks everybody
Frida Vega
|
|
|
|
|
Dear :
I need information for how to make ISAPI redirection filter in c++, i used to make redirection using MFC ISAPI Filter class like this : in OnUrlMap function
[CODE]
char chHeader[1024] ;
sprintf(chHeader,"Location:%s\r\n","/Error.htm");
DWORD dwchHeader = sizeof(chHeader);
pCtxt->ServerSupportFunction(SF_REQ_SEND_RESPONSE_HEADER,"302 Object Moved",(LPDWORD)chHeader,NULL);
return SF_STATUS_REQ_FINISHED_KEEP_CONN;
[/CODE]
but sometime this does not work, I mean it wont redirect (is above code not correct?) ,if so I need a methods to how redirect to other URL permanently other than above method.
Regards
|
|
|
|
|
Is it possible to detect if a mmodem is currently connected/ in use etc.
If so how?
Steve
|
|
|
|
|
|
Thanks for your prompt reply.
I'm not sure if that's what I want really.
What I really want my app to do, is watch the modem for a remote connection (company dialling in), then when it sees a connection, to disable the LAN.
Obviously when they disconnect to re-enable the LAN.
Thanks
Steve
|
|
|
|
|
Does anyone know how to go about disabling a network adapter.
I just want to do want your able to do if you right click on you network connection in the tray.
Steve
|
|
|
|
|
try [NETSH]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hello,
i try to put a working code snip from an mfc .exe project into a .dll project. In the code an EVENTSINKMAP is linked to an activex control in my "old" mfc exe. The .dll should start working when an event occures from this activex control:
BEGIN_EVENTSINK_MAP(CSavepmjxApp, CWinApp)
ON_EVENT(CSavepmjxApp, IDC_SCANCONTROL, 1 , OnScanReadyRealscan1, VTS_UNKNOWN)
END_EVENTSINK_MAP()
The compiler gives an error because IDC_SCANCONTROL is unknown in my .dll project.
I like to use this .dll later in VisualBasic where i have my activex control again. How can i make this work??
happy coding,
-mark
|
|
|
|
|
I have failed to set the bi-directional bit of the parallel port using the "inpout32.dll". Each time I write to the control port a value that would translate to setting the bi-directional bit to "1", the value that is ultimately written is one which does not set the bi-directional bit. E.g. writing "32" to the control register which would translate to the bi-directinal bit being set to "1", results in "192" being written to the control register. "192" is a value which when converted to binary results in the bi-directional bit not being set. Any idea to what the problem might be?
So help me God!
|
|
|
|
|
I'm building a treeview in a virtual CListCtrl, i've got almost everything working except for one thing:
When you click an item in a listview it gets selected on the mouse down.
When you click a node in a tree view it gets selected on the mouse up.
This means that when you drag an item from the listview you're always dragging the selected item.
But in a treeview you can drag an item that is not the current selected item. And when you're done dragging the selected item becomes active again.
So what i'm looking for is a way to disable the item select in a listview on the mouse down.
Can anyone help me?
|
|
|
|
|
In C++ language, is there a command to convert ASCII to HEXADECIMAL value? Like 'atoi', whereby this is a conversion from ascii to ingteer !!!! So, anyone pls know, pls reply. Thanks!
|
|
|
|
|
Have a look at
this[^] thread. You might also want to try searching previous post if this doesn't help.
If all else fails, clarify your question and we should be able to help further.
I Dream of Absolute Zero
|
|
|
|
|
There's no such thing as converting ASCII to hexidecimal. One is not like the other. Perhaps you wanted to know how to convert from base 10 to base 16.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
|
Hello Techies,
How can I retrieve the path from where the application is being executed? This path should be retrieved at the initialization process itself.
Thank you,
Bye
Neelesh Jain
|
|
|
|
|
Use GetModuleFileName , passing NULL in for the hModule parameter.
|
|
|
|
|
Thank you Graham, But when I used the above function in the following way
GetModuleFileName(NULL,LPTSTR(path),1000);
It gave me an memory exception mentioning that it cann't read the memory.
path is a type of char pointer.
I had declared path as char* path;
|
|
|
|
|
It sounds as if you haven't allocated the memory - GetModuleFileName won't do that for you.
Try:
char path[1000];<br />
GetModuleFileName(NULL, path, 1000);
This statically allocates 1000 characters for the path variable.
|
|
|
|
|
Hi Graham,
Thank you for ur suggestion, its working, but its retrieving the file name also. I want to know only the path. For eg., If the application is present in C:\my document\Testing, then its displaying as C:\my document\testing\Test.exe
but i want to display only C:\my document\Testing. The application file should be displayed.
Bye
Thank you once again
Regards,
Neelesh
Neelesh Jain.
|
|
|
|
|
The easiest way to do this is to parse the returned string and find the last '\'. If you terminate the string there you will get just the path as you require.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|