|
Thanks for the help. I find that the Text Gets Shrunk rather than Get Bold ?
|
|
|
|
|
??? Sure you're changing the weight and not the width? Don't know, try playing with the various params of LOGFONT .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Here's the situation:
I have a program that runs in the system tray, and I want to be able to open a Dialog that sits on top and has focus over all programs currently running (kind of like a system message from Windows). Since DoModal does not accomplish this, is there something else I can do? Thanks.
Todd
|
|
|
|
|
One solution is to override the event handler for ON_KILLFOCUS. Call SetFocus().
Kuphryn
|
|
|
|
|
Did you really mean the focus? (where keyboard input is sent)
Or are you looking to make the window topmost, activated and
prevent activation of other windows until yours is dismissed?
(handling WM_ACTIVATEAPP and using AttachThreadInput and
SetForegroundWindow to reassume the foreground if the user
tries to switch to another window. ick )
|
|
|
|
|
Yes, I am looking to make the window topmost, activated and
prevent activation of other windows until mine is dismissed. I didn't mean keyboard focus. Sorry.
|
|
|
|
|
Hey All,
I have a SDI application.
Using the default print and preview messages (ID_FILE_PRINT & ID_FILE_PREVIEW) I am able to successfully Print and Preview my document.
I have a problem though...
When my application is in Preview Mode and I try to close the Preview window by clicking 'x' in the system menu (upper right hand corner) instead of using the 'close' button in the preview window, my entire application closes. I don't desire that. I just want to get my preview window closed. Any suggestions?? (It works fine by using the 'close' button)
Thanks,
-Mahesh Shimpi
Ideas multiply by sharing!!
|
|
|
|
|
Hello,
I am having a little problems with sockets.. Heres a break down.. I have a server application running on two machines.. The servers send and receive each others status every 60 seconds..
Both servers are listening.. One server will spawn a UI thread and do a connect. If the connect is successful it sends it's own status (like.. "ON_LINE") after it sends it's status, the other server receiving the status turns around and sends it's status through the same socket..
This all works fine except I don't know how to close the socket with out leaving a TIME_WAIT behind.. (I am using sysinternals TCPView to view my end points).. I have tried to issue a shutdown(s,SD_SEND) after my sends then after a FD_READ i do a shutdown(s, SD_RECEIVE) but no matter what I do I allways see a TIME_WAIT hanging around for a few minutes.. I'm not really sure if this is a bad thing but I plan on running this software on quite a few pc's and if these TIME_WAITS are using up resources I could have a big problem..
Any ideas?
Thanks!!
Rob
|
|
|
|
|
Consider Shutdown(). Another solution is to set the LINGER structure to 0 and use setsockopt() to instruct the socket to close immediately.
Kuphryn
|
|
|
|
|
Thanks for the reply.. I have been trying to use the SO_LINGER but it doesn't seem to be working.. here's what I'm trying..
First create.. then
linger m_linger;
m_linger.l_onoff = 1; // Turn linger on
m_linger.l_linger = 0; // Set time to ZERO
s.SetSockOpt(SO_LINGER, &m_linger, sizeof(m_linger),SOL_SOCKET);
This isn't working, am I doing this wrong?
Thanks,
Rob
|
|
|
|
|
No. Your solution looks okay. What happens when you set the time to greater than 0?
Kuphryn
|
|
|
|
|
I think I found the problem.. I was using API then I switched to using CAsyncSocket then to CSocket.. Just found out that SO_LINGER doesnt work with CSocket so I'm going to go back to either CAsync or straight API (if thats what you call it)..
Any way .. Thanks,
Rob
|
|
|
|
|
Hi everyone,
I have a thread. The function that keeps this thread alive contains a while loop. The while loop is true while a boolean variable is maintained true. When the thread has to terminate, the boolean value is modified to false and the thread dies. This boolean variable is global. I am using a Mutex to control access to this global value.
I would like to know if it is necessary to control global variables with a Mutex when one is just reading the value? Or does one only control the global variable when one is going to modify its value?
This one depends on the previous question. How does one manage something like:
while ( g_bGlobal_Variable )
{
}
How does one apply a mutex object to the above case. Because I cannot do
dwWait = ::WaitForSingleObject();
if ( dwWait == 0 )
{
while ( g_bGlobal_Variable )
{
}
}
Otherwise this implies that the thread always has control over the Mutex object while alive.
Thanks and excuse the ignorance
Regards
|
|
|
|
|
First, if you're going to use a synhcronization object to
protect a flag, use the synchronization object as the flag.
i.e. Use an Event whose state is checked as a condition to exit
the thread. (better yet use two events.. one to signal work to
be done, the other to exit. wait (WaitForMultipleObjects) on both
and then react appropriately.. that way your work thread won't
waste cycles running through loops pointlessly.)
Second, yes. Even access to resources should be protected (generally)
since you want to ensure that the resource is not being modified while
you are reading it. (or whatever)
That said, some types of resources (small register-sized variables
generally) can be read/written without the need of a protecting
synchronization object. Check out the Interlocked_______ functions
in win32.
|
|
|
|
|
Thanks Scott
I am sorry for the anonymous that was an error.
Rui
|
|
|
|
|
Here's a code sample:
HANDLE hWorkToBeDone=CreateEvent(0,FALSE,FALSE,0);
HANDLE hTimeToQuit=CreateEvent(0,TRUE,FALSE,0);
HANDLE Waitables[]={hTimeToQuit,hWorkToBeDone};
for (DWORD W=~WAIT_OBJECT_0;W!=WAIT_OBJECT_0;)
{
switch (W=WaitForMultipleObjects(2,Waitables,FALSE,INFINITE))
{
case WAIT_FAILED:
break;
case WAIT_OBJECT_0:
break;
case WAIT_OBJECT_0+1:
;
break;
case WAIT_TIMEOUT:
default:
ASSERT(FALSE);
}
}
|
|
|
|
|
|
I have an animation control on a dialog box that displays an AVI file while some processing is taking place. I create the animation control and play it from my WM_INITDIALOG handler. However, sometimes I notice that the animation takes a second or two to start playing. Any suggestions on what I can do to make sure this animation comes up all the time?
Brigg Thorp
Software Engineer
Timex Corporation
|
|
|
|
|
Hmm, never used that control before.
Can you create the hosting dialog as a hidden
modeless dialog (some time before ever
needed) and just pop it up, disabling
the main window, when needed? (Call animation
control's Seek method when creating dialog,
and Play in you OnShowWindow handler)
That way, hopefully the animation is ready to
play when you need it.
|
|
|
|
|
Hello all,
This is a basic question in MFC, but for some odd reason I can't figure out how to do it. I want to be able to specify the size of the main window when it comes up, and would like to be able to save this information (via .ini file I suppose). I thought that by modifying the CreateStruct in the OnCreate or the OnPreCreate would handle this setting the initiail size of the main window, but it does not work. Any suggestions on how to do this, and could anyone point me in the right direction to "save" this window information so when it comes up again I can use the last position/size information.
Thank you in advance.
Dan
|
|
|
|
|
There are some articles on how to do this somewhere on this very site...
When I am king, you will be first against the wall.
|
|
|
|
|
|
add this in CMainFrame::OnCreate() :
SetWindowPos(NULL, 0,0, 600,350,SWP_NOZORDER|SWP_NOMOVE);
|
|
|
|
|
In addition to S.Rod.'s answer you can also use
MoveWindow(200,100,450,300,TRUE);
This will change the size and move it around the screen
Also,
GetClientRect(&rcClient); // get size of client area
m_cyClient = rcClient.bottom-rcClient.top; // only the 'y' length
Will get the size of the window.
To get the left and right sides you can rcClient.Right-rcClien.Right
Jeff Patterson
Programmers speak in Code.
www.anti-dmca.org
|
|
|
|
|
Hello all
I have a VC7 dialog based application.
Basically one dialog with
an edit box
IDC_EDIT
and 2 buttons
IDC_READ_MYFILE
IDC_CANCEL
when I press the IDC_READ_MYFILE button i want to open a standard File Open Dialog, managed by the message_map entry, something like this:
ON_BN_CLICKED(IDC_READ_MYFILE, OnReadMyfile)
...
void CMyAppDlg::OnReadMyfile()
{
// TODO: Add your control notification handler code here
static CString szFilter = "DXF Files (*.dxf)|*.dxf||";
CFileDialog fileDialog(TRUE, "dxf", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, NULL );
if(fileDialog.DoModal() == IDOK)
{
CString sDXF_FileName;
sDXF_FileName = fileDialog.GetPathName();
... do some processing on this file
UpdateData(FALSE);
}
}
Tested under windows XP it *works fine* (opening the File Dialog and processing the selected file as needed) but under windows 98 it works but when pressing on the IDC_READ_MYFILE button nothing happens (the File Open dialog is not open) while the close button works and also the about message box works (called inside the dialog top left System menu)
By the way I have checked the resources IDs and there isn't any conflict
any help/tips will be greatly appreciated
thanks in advance!
best regards
|
|
|
|