|
who is given you 1 vote every now or then.. let me square it out again! keep up your good work!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Thnaks again Alok.
|
|
|
|
|
Hi,
I have a window which I want to see as always visible and active to the users. I have placed the window on top portion of the screen. Now I want all other windows(could be any window) below that window. I guess there should be an API which sets a region(boundary) for windows to be placed in. Can some one help me.
Thanks.
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg."
- Bjarne Stroustrup
|
|
|
|
|
You can set your window to be a topmost window, so all other not topmost window will be under your window!
Use SetWindowPos() API.
|
|
|
|
|
We are preparing to upgrade our C/C++ apps from Visual Studio 6.0 to VS 2005. We have heard that VS 2005 no longer supports the standard C language calls (memcpy, memcmp, strcpy, etc) that we use frequently in most of our source code, and have used since back in the 1980's. Does anyone know if VS 2005 no longer allows these function calls directly?
Thanks, Mike
|
|
|
|
|
|
However, they are not actually deprecated according to the C++0x standard.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Those functions are fine -- they'll generate warnings.
The warning states what the 'better function' is and also how to disable the warning...
Before you decide though, you really should do a test compile under VS2005 to determine what other issues you might run into.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
I posted this in the VS forum, but I guess its more specific to C++...
I'm using VS.NET 2005 and building a large application with about 100 projects.
There is one project in the solution that compiles to a DLL that I need to debug. (i.e. break, and step into the code) However I can't. In the modules tab of the IDE, it says that no symbols have been loaded for that module. I know the pdb is being generated though, has the same filename as my dll, and is being generated in the same directory as the dll. The timestamps match as well, and I'm building the debug configuration.
When I right click on the module in the modules tab and goto "Load Symbols" and point it to my pdb it says that "The symbol file xyz.pdb does not match the module"
What could possibly be going wrong?
|
|
|
|
|
It is possible that the pdb is stripped of its symbols. This is done in deployment to lessen the install footprint. It is also possible that the pdb is not generated from the code that generated the dll.
Pax Domini sit semper vobiscum
|
|
|
|
|
I found the problem,
I had the VTune plugin installed in my VS install, when I removed it, I was able to debug ok. My guess is that the VTune plugin somehow messed up the pdb generation.
|
|
|
|
|
I'm trying to save a file to a fixed location. The would like file to be saved in the same folder as the executable, so I am using a relative path. However, I get mixed results. Sometimes it saves to the proper folder, sometimes to desktop, and sometimes to C:\.
If I use an absolute path, the problem goes away. So my question is whether the path specified when opening the file is required to be absolute? And if so, how can I get an absolute path from a relative path not knowing where the executable will be installed?
Here is my code:
CStdioFile LcfIniFile;
CString LcsTempStr;
if (LcfIniFile.Open("test.ini", CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite | CFile::typeText | CFile::shareDenyWrite))
{
...
LcfIniFile.WriteString(LcsTempStr);
LcfIniFile.Close();
}
Thanks.
Edit: MSDN says path can be relative, absolute, or network name. So now I really don't know what I'm doing wrong.
Edit2: I should also note that reading the file using the relative path did not cause any problems, it was only during write.
-- modified at 15:49 Wednesday 24th October, 2007
|
|
|
|
|
I think it all depends on what the current directory is.
And that all depends on how you run it....
Why not construct an explicit path to the file -- that way you can be sure.
use GetModuleFileName to determine the path of the exe...
split off the name and add "test.ini"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
How do I terminate my CWinThread from my main UI thread -- without blocking anything.
I was thinking I'd try something like:
PostThreadMessage( WM_QUIT, 0, 0 );
MSG msg;
while( PeekMessage(&msg, NULL, 0,0, PM_REMOVE ) )
{
if ( WaitForSingleObject(m_hThread,0) == WAIT_OBJECT_0 )
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
But that doesn't seem to work...
Any suggestions?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
or what about:
if I set m_bAutoDelete to FALSE
and:
PostThreadMessage( WM_QUIT, 0, 0 );
while ( PumpMessage() )
{
if ( WaitForSingleObject(m_hThread,0) == WAIT_OBJECT_0 )
break;
}
delete this;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
An example:
In your class which creates the thread:
private:
HANDLE m_StopThread;
HANDLE m_WaitThread;
static UINT ThreadFunction(LPVOID pvParam);
When you create your thread:
// Create events
m_StopThread = CreateEvent(0, TRUE, FALSE, 0);
m_WaitThread = CreateEvent(0, TRUE, FALSE, 0);
// Start thread
AfxBeginThread(ThreadFunction, this);
When you want to terminate the thread:
// Trigger thread to stop
::SetEvent(m_StopThread);
// Wait until thread finished
::WaitForSingleObject(m_WaitThread, INFINITE);
// Close handles
::CloseHandle(m_StopThread);
::CloseHandle(m_WaitThread);
//Your thread procedure
UINT CFoo::ThreadFunction(LPVOID* pvParam)
{
CFoo *pParent = static_cast<cfoo*>(pvParam);
while(true)
{
// Check event for stop thread
if(::WaitForSingleObject(pParent->m_StopThread, 0) == WAIT_OBJECT_0)
{
// Set event
::SetEvent(pParent->m_WaitThread);
return 0;
}
// Do your processing
}
}
Hope this helps you out!
|
|
|
|
|
That will only work if the thread has a message pump - i.e. is created as a UI thread. If it is a worker thread, I usually do the following (error checking removed for the sake of brevity):
in the main UI thread:
m_hTermEvent = CreateEvent (NULL, TRUE, FALSE, NULL);
m_pThread = AfxBeginThread (ThreadFunction, &m_hTermEvent);
SetEvent (m_hTermEvent);
WaitForSingleObject (m_pThread->m_hThread, INFINITE);
in the worker thread:
UINT __cdecl ThreadFunction( LPVOID pParam )
{
HANDLE hEvent;
hEvent = *((HANDLE *) pParam);
while (true)
{
if WaitForSingleObject (hEvent, 0) == WAIT_OBJECT_0)
break;
};
return 0;
}
Judy
|
|
|
|
|
That is NOT the case. This works as it should for worker threads!
Please, show me what in my code would not work!
|
|
|
|
|
pierre_ribery wrote: That is NOT the case. This works as it should for worker threads!
Please, show me what in my code would not work!
Calm down dude. No need to get snippy. I wasn't responding to your post, I was responding to the original poster. The presence of my post does not imply that yours is wrong. If you'll check the time stamp, we were posting at the same time. Your post didn't exist when I started mine.
Judy
|
|
|
|
|
Maybe I should go back to basic threading.
CWinThread is a UI thread in this case -- and has a message pump.
It seems that if I wait for it to terminate, then I am blocking my UI thread.
So, it seems I need to pump messages while I wait.
Or, do I have no clue?
More likely, I am just making this harder than it needs to be.
But, the goal is to wait for this thing to terminate completely.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Are you terminating a UI thread from within itself as you're showing
in your code or do you want to terminate a thread from another
thread and wait?
For the latter, maybe something like this:
OtherCWinThread.PostThreadMessage(WM_QUIT, 0, 0);
while (1)
{
DWORD dwWaitRet = ::MsgWaitForMultipleObjects(1, &OtherCWinThread.m_hThread, FALSE, INFINITE, QS_ALLEVENTS);
if (dwWaitRet != WAIT_OBJECT_0 + 1)
break;
MSG msg;
while ( ::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
AfxGetApp()-> PumpMessage();
}
}
mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you! -- I knew someone would understand the question!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
ah! insight!
I never quite made the distinction.
Thanks!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Attached below is the program... but it fails to execute!!
When i tried to execute: Cimg0Exception window pop up with the msg: CImg<unsined char="">::load_other():Failed to open image 'piggy.jpg". Check you have either the ImageMagick or GraphicsMagick package installed.
How do i install??(mine is Windows XP)
#include "CImg.h"
using namespace cimg_library;
int main() {
CImg<unsigned char=""> image("piggy.jpg"), visu(500,400,1,3,0);
const unsigned char red[] = { 255,0,0 }, green[] = { 0,255,0 }, blue[] = { 0,0,255 };
image.blur(2.5);
CImgDisplay main_disp(image,"Click a point"), draw_disp(visu,"Intensity profile");
while (!main_disp.is_closed && !draw_disp.is_closed) {
main_disp.wait();
if (main_disp.button && main_disp.mouse_y>=0) {
const int y = main_disp.mouse_y;
visu.fill(0).draw_graph(image.get_crop(0,y,0,0,image.dimx()-1,y,0,0),red,0,256,0);
visu.draw_graph(image.get_crop(0,y,0,1,image.dimx()-1,y,0,1),green,0,256,0);
visu.draw_graph(image.get_crop(0,y,0,2,image.dimx()-1,y,0,2),blue,0,256,0).display(draw_disp);
}
}
return 0;
}
|
|
|
|
|
purplee85 wrote: How do i install??(mine is Windows XP)
Please don't repost your questions. You can modify your original post to add the code. Of course in this case the code is irrelevant since you already told us you don't know how to install the library.
|
|
|
|
|