|
Hi,
I need a little help here from the community members, I'll appreciate if you share any information about this problem if you saw it and tried to fix it or actually fixed it. The product I am working on invloves OpenGL APIs, but
1) On Windows XP
2) and on all kinds of Graphics cards we have (Nvidia, Wild Cat) here at the office
Windows desktop tooltips get completely garbled after a call to wglMakeCurrent function. As soon as the window whose DC was used in wglMakeCurrent call is destroyed, the tooltips come back.
By tooltips getting garbled, I mean that hovering mouse over program buttons in the taskbar would show wrong information for running programs, the tooltip window's size would be either smaller than the size the tooltip's text can fit in, or too much large showing the extra area as shadow or black color.
Any hints.. ideas?
Yawar
|
|
|
|
|
I have a function in my tcp server that starts a thread to try and stop the server, i'm using a thread because when the server stops, things have to be removed from a list of clients, and so it cant block the message queu or i cant use SendMessage(). The problem is that when i test, by connecting via telnet, and stop the server while the client is connected, WaitForMultipleObjects() usually returns WAIT_FAILED with error code 6 (Invalid handle). Only the first time i stop the server it sometimes works ok. But after that its always WAIT_FAILED. HEre's the code to the stopper thread:
DWORD WINAPI StopServerThread(void* prms)
{
HWND hWnd = (HWND)prms;
HL thread;
HLI hli;
int result=0;
shutdown(sListener,SD_BOTH);
closesocket(sListener);
if(client.size()>0)
{
DWORD err;
for(cli=client.begin();cli!=client.end();++cli)
{
thread.push_back((HANDLE)(*cli)->ThreadHandle);
}
if(!WSASetEvent(hSuicideEvent))
MessageBox(hWnd,"WSASetEvent() failed","Error",MB_ICONERROR);
result = WaitForMultipleObjects( thread.size(), thread.begin(), TRUE, 5000 );
switch ( result )
{
case WAIT_TIMEOUT:
ConsoleOutput("Not all threads died in time");
break;
case WAIT_FAILED:
err = GetLastError();
ConsoleOutput("WaitForMultipleObjects(): WAIT_FAILED (%i)", (int)err);
break;
default:
ConsoleOutput("All client threads terminated successfully");
break;
}
for ( hli = thread.begin(); hli != thread.end(); ++ hli )
CloseHandle( *hli );
client.clear();
thread.clear();
}
DeleteCriticalSection(&lpCritSection);
WSACloseEvent(hSuicideEvent);
bIsRunning = FALSE;
HMENU mainmenu = GetMenu(hWnd);
EnableMenuItem(mainmenu,IDM_START,MF_ENABLED);
EnableMenuItem(mainmenu,IDM_STOP,MF_GRAYED);
ExitThread(0);
return 0;
}
client is a list of client information, also containing the thread handles of each client thread. Weird thing is that the client threads DO exit and all, everything works fine except that WaitForMultipleObjects starts to return WAIT_FAILED. Anyone have any idea why?
Thanks
Kuniva
--------------------------------------------
|
|
|
|
|
I was getting this problem a couple of years ago. It was very frustrating until I read the chapter on threading in Jeff Prosise's book Programming Windows with MFC.
If the threads were created using AfxBeginThread which returns a CWinThread* then what is happening is that when at least one thread finishes the CWinThread is automatically deleting the thread handle which will cause WaitForMultipleObjects to return failed because at least one handle is invalid (closed). One way to resolve this is to create the thread suspended, duplicate the handle, and finally resume the thread. This means that the duplicate handle will be valid until YOU close it. Here is a simple code snippet:
CWinThread* pThread = AfxBeginThread(ThreadFunc, lpData, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
::DuplicateHandle(AfxGetProcess(), pThread->m_hThread, AfxGetProcess(), &hThread, 0, FALSE, DUPLICATE_SAME_ACCESS);
pThread->ResumeThread();
...
...
::WaitForMultipleObjects...
::CloseHandle(hThread);
This is VERY abbreviated code but it should give you the general idea.
Kelly Herald
Software Developer
MPC
|
|
|
|
|
Hi! Thanks for replying I think you may have a point here, even though i'm not working in MFC, but i think there might be the possibility that the thread handle is closed before i call WaitForMultipleObjects() so i'll now try DuplicateHandle() and see if that works. Thanks!
Kuniva
--------------------------------------------
|
|
|
|
|
Yes! this fixed it, thanks!
Kuniva
--------------------------------------------
|
|
|
|
|
I hope HL is a typedef for vector< HANDLE > . Only vector among the STL containers guarantees that all contained items are contiguous (i.e. at adjacent memory locations), which is what WaitForMultipleObjects requires.
|
|
|
|
|
Yea, it is, thanks for replying
Kuniva
--------------------------------------------
|
|
|
|
|
Hi
I am not using mfc or any kind of complex thing
I just work with windows forms using c++.
My question is how can I have a have the following.
by clicking the fist Button. user starsts a while loop. In the loop a series of events take place, and then we ask the user to input something to textBox. user enters the data and,clicks the 2nd Button. the program gets the data and goes back to the loop continueing its job.
what i have so far is :
private: System::Void 1stbtn_Click(System::Object * sender, System::EventArgs * e)
{
while (mycondition is true)
{
...do the job
wait for 2ndbtn to be pressed;
...do the job
}
}
private: System::Void 2ndbtn_Click(System::Object * sender, System::EventArgs * e)
{
lol = textBox->Text;
}
|
|
|
|
|
I have a IDR_MAINFRAME with a menu called Lab6. Under it i have two menu's Lab4 and Relationship. I have two Dialog IDD_FAMAPP_FORM and IDD_FAMAPP_RELATION. when i run the application the default view is the IDD_FAMAPP_FORM. I am trying to write a code that switches the view when i click the menu item. I have this following code:
void CMainFrame::SelectView(UINT ViewID)
{
CFrameWnd* pMainWnd = (CFrameWnd*)AfxGetMainWnd();
CView* pOldActiveView = pMainWnd->GetActiveView(); // Get current view
// Get pointer to new view if it exists
// if it doesn't the pointer will be null
CView* pNewActiveView = (CView*)GetDlgItem(ViewID); - It is blowing right on this code, not going beyond this.
Please can someone let me know how to switch views with the scenario i have.
|
|
|
|
|
|
I have started writing a class to create a d3d window, but every time i make a call to BeginScene,EndScene or Present my computer restarts. The following is my d3d initiation code which i run after creating a window, and then i try to run the functions from my main message loop. Could anyone please help, I'm having trouble debugging soon as my computer reboots everytime it doesnt work.
if((procIdle==NULL)||(procRender==NULL)||(procPreRender==NULL))return 1;
if(FAILED(lpD3D = Direct3DCreate9(D3D_SDK_VERSION)))return 2;
if(FAILED(lpD3D->CreateDevice
(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd
,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&prm,&lpDevice)))return 3;
for(int i = 0;i < 209; i++)
if(render_states[i]!=NULL)
if(FAILED(lpDevice->SetRenderState
((D3DRENDERSTATETYPE)i,render_states[i])))return 4;;;
initiated = true;
return 0;
|
|
|
|
|
The computer restarting points to a driver bug.
Are you using the latest drivers for your video card?
Are you testing with the debug D3D runtime?
- Mike
|
|
|
|
|
Hi,
i have inherited a class from CEdit, and want to send my application a user defined message from this class. i have used PostMessage function for that reason from my class's LBUTTONDOWN message.
The message is captured by my window (a dialog box that has an edit box linked by a variable of my class) and works well while i work in Debug configuration, but causes an unhandled exception in Release Configuration .
I would be obliged if any one can help me..
--------
THE CODE SAMPLE:
--------
Dev. Platform : VC++ 6.0
OS: Windows 2000 Professional
//class definition
class CMyClass : public CEdit
{
...
}
Void CMyClass::OnLButtonDown(UINT nFlags, CPoint point)
{
// my code...
....
CEdit::OnLButtonDown(nFlags, point);
//m_hParWnd is the handle of parent dialog claas
::PostMessage(m_hParWnd, TOGGLE, 0, 0);
}
/*My applications main dialog with a member variable of CMyClass associated with an edit box*/
..
ON_MESSAGE(TOGGLE, OnToggle)
...
CMyAppDlg::OnToggle()
{
....
}
Kind Regards
Siddique Ahmed
Senior Software Engineer
Telelogix Software
(www.telelogix.com)
|
|
|
|
|
Sid_smily wrote:
::PostMessage(m_hParWnd, TOGGLE, 0, 0);
Is m_hParWnd non-NULL ? If you comment out this statement, does the UE still occur? Does anything special happen within the OnToggle() method?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
You are defining an incorrect handling function in your CMyAppDlg , the right way to do so is:
class CMyAppDlg : public CDialog
{
afx_msg LRESULT OnToggle(WPARAM wParam, LPARAM lParam);
}
ON_MESSAGE(TOGGLE, OnToggle)
LRESULT CMyAppDlg::OnToggle(WPARAM wParam, LPARAM lParam)
{
return (LRESULT)0;
}
This will work fine.
|
|
|
|
|
I do not understand how to use this API. Like I need a little bit more information then what MSDN has to offer and some of the sample code on CP. This is what I am trying to do. I am trying to make it so that when I send a WM_CLOSE message the window fades slowly away. But if I use SetLayeredWindowAttributes(), works no problem. But I want to use UpdateLayeredWindow(). I have tried everything to get it to render the window. Sometimes just the copy of my IDE shows up. Now How do I set this function up??? I am coding in win32 C/C++ -> No MFC. Any help would be great. I have spent 2 days trying to figure this crap out. With no help from anywhere except u guys. But I dont understand all the MFC code to dissect it.
Thank You
Gino
|
|
|
|
|
Hi fellow programmers!
I was wondering what is the latest beta of Visual Studio .NET that can compile AMD64 code for Windows XP 64-bit?
Thanks for your answers!
Rob
|
|
|
|
|
Currently the only shipping AMD64 compiler from Microsoft is in the Driver Developers' Kit[^]. The same is also true for the Itanium compiler.
These are only command-line compilers, so you should consider using a separate build tool, such as the DDK's BUILD.EXE, NMAKE.EXE or NAnt[^].
The x86 compiler is basically the same one that VS.NET uses (VS.NET compiles by running the cl.exe program).
I'd be impressed if you'd managed to get hold of an AMD64 system running Windows XP 64-bit, because that hasn't been released yet, IIRC. If you've only installed the regular version of Windows XP, you won't be able to run native 64-bit programs. The compilers in the DDK are cross-compilers - they are actually 32-bit x86 programs, but they build for the appropriate platform (although MS does supply an Itanium-native Itanium compiler).
|
|
|
|
|
Thanks for your reply.
I am an independant developer, developing a software for AMD. I have their fullsuppot and will be getting the latest build of Windows XP 64-bit next week. I am not at liberty to say more about the project or I would have.
I know I read somewhere that there is a beta of Visual Studio.NET with AMD64 available in the IDE. I already asked my contact in AMD for that. And will post the answer here if possible.
|
|
|
|
|
Anyone knows what kind of window is the one that holds our files in Visual Studio .NET ? The Window as a nice property that i would like to use that is, auto-hide. The window shows up when we pass the mouse cursor over it and automatically gets hidden when the mouse cursor isn't on top of it. Anyone ?
Thanks.
|
|
|
|
|
This is custom implimented behaviour, not behaviour you can get from deriving from an existing class in the framework.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
what's the name of that window ?
|
|
|
|
|
Fred.
Seriously, what are you trying to do ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I have several CControlBar derived bars attached to a CFrameWnd.
It seems the horizontal bars always have stretch priority over the vertical ones (more or less like borderlayout in java).
example: the bottom bar is always stretched from left to right first, so the right bar cannot stretch to the bottom anymore.
But I would like the right bar stretched to the bottom, before the bottom bar is streched.
How can I change this?
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
i need to create a resource assembly that contains a bunch of gifs. the gifs need to be displayed dynamically. how would i accomplish this? i added an assembly resource file to my project, then used resgen to create the .resource file, but i can't figure out how to add gifs to it. i feel like i am missing something obvious.
thanks.
|
|
|
|