|
I am using Microlsoft Visual Studio 6.00.
I am creating a new frame using CreateNewFrame(). At the time of creation of class I derive the class from CScrollView. I want to paint the background of the view with some color. So I am using SetBkColor as
pDC->SetBkColor(RGB(255,0,0))
Here 'pDC' is of OnDraw() method.
But it can't work.
Plz tell me how can I paint the background window.
Regards
Nikesh
|
|
|
|
|
I hope this will help you [^]
|
|
|
|
|
i have created a sample application with SetCursorPos().
this application moves the mouse cursor to a certain extent when clicking on a button.
This application works fine with my system.
However it doesnt work in VMware workstation. why?
|
|
|
|
|
http://communities.vmware.com/thread/189519[^]
Please see below :-
In order for SetCursorPos() or Mouse_Event() to behave the way you would expect, you can disable the absolute mouse and host cursor offload, by adding the following to the VM's .vmx file and rebooting.
vmmouse.present = FALSE
modified on Friday, July 10, 2009 8:52 AM
|
|
|
|
|
Hi,
I am trying to enable Boost multi threading in Visual Studio 2003.
<br />
#include < boost/thread/thread.hpp >
#include < boost/lambda/lambda.hpp >
int main()<br />
{ <br />
<br />
<br />
return 0;<br />
}<br />
I went to PROJECT -> PROPERTIES -> C/C++ -> COMMAND LINE and added /MT
but I get the following compile errors
<br />
main Command line warning D4025 : overriding '/MLd' with '/MT'<br />
main Command line warning D4025 : overriding '/MT' with '/MLd'<br />
main Command line warning D4025 : overriding '/MLd' with '/MT'<br />
main fatal error LNK1104: cannot open file 'libboost_thread-vc71-mt-sgd-1_38.lib'<br />
does anyone know how to switch it on? Had a scout round on the net but to no avail
Thanks for any information.
|
|
|
|
|
You set that with the C/C++->Code Generation->Runtime Library project property rather than on the command-line. Also, you need to set different options for Debug and Release builds.
[edit] And please remove the /MT from the Command Line properties![/edit]
In addition, you either haven't told the linker where to find the Boost libraries (use the Linker->General->Additional Library Directories project property) or haven't built them completely (or did you use the Boost Consulting installer?).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Wow, did'nt realise there was so much to do.
I ran
<br />
bjam --build-dir="c:\program files\boost\boost_1_38\lib" --toolset=msvc --build-type=complete stage<br />
where I have the bjam exe in the \boost_1_38\ directory but it gives an error
<br />
*** argument error<br />
* rule path.make ( native )<br />
* called with: ( )<br />
* missing argument native<br />
C:/Program Files/boost/boost_1_38/tools/build/v2/util\path.jam:44:see definition of rule 'make' being called<br />
C:/Program Files/boost/boost_1_38/tools/build/v2/tools\msvc.jam:184: in configure<br />
C:/Program Files/boost/boost_1_38/tools/build/v2/tools\msvc.jam:137: in msvc.init<br />
C:/Program Files/boost/boost_1_38/tools/build/v2/build\toolset.jam:38: in toolset.using<br />
C:/Program Files/boost/boost_1_38/tools/build/v2/build\project.jam:862: in using<br />
C:\Program Files\boost\boost_1_38\tools/build/v2\user-config.jam:59: in modules.load<br />
C:/Program Files/boost/boost_1_38/tools/build/v2\build-system.jam:241: in load-config<br />
C:/Program Files/boost/boost_1_38/tools/build/v2\build-system.jam:383: in load-configuration-files<br />
C:/Program Files/boost/boost_1_38/tools/build/v2\build-system.jam:520: in load<br />
C:\Program Files\boost\boost_1_38\tools\build\v2/kernel\modules.jam:283: in import<br />
C:\Program Files\boost\boost_1_38\tools\build\v2\kernel\bootstrap.jam:138: in boost-build<br />
C:\Program Files\boost\boost_1_38\boost-build.jam:16: in module scope<br />
Ummm, any ideas?
|
|
|
|
|
This is the command -line I used, from the root of my Boost 1.38.0 source unpack
bjam --toolset=msvc-7.1 --prefix=d:\lib\boost --build-type=complete install
My Boost libraries are in this sort of directory hierarchy:
- d:\lib\boost - Root of my Boost install - I've only got 7 versions of Boost installed. from 1.32.0 on . You can see that I've told bjam that this directory is the root of my Boost library directory hierarchy.
- d:\lib\boost\include - contains all Boost header files in versioned sub-directories, such as D:\lib\boost\include\boost-1_38. Each versioned sub-directory contains a boost sub-directory which is the root of the include directory hierarchy. The versioned sub-directory is automatically created by the 'install' action in the jam file
- d:\lib\boost\lib - contains all Boost libraries and DLLs. The libs and DLLs are copied here by the 'install' action in the jam file
- d:\lib\boost\versioned directory containing source, docs etc. For example, D:\lib\boost\boost_1_38_0 for Boost 1.38.0. I
CD into this directory before building that version of Boost. After building, I delete the bin.v2 directory, as it contains all the object files created by hte build process, which can be > 1GB in size.
I would certainly recommend using this sort of setup, as it's worked pretty flawlessly for me for (literally) years.
The other thing I'd be concerned about with your setup is the 'Program Files' directory - I'm always worried about command-line tools and directories whose names contain spaces.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hmmm, I uninstalled my Boost folder from the previous location and installed it again in "C:\boost" so I can remove the space.
I ran your commaned
<br />
bjam --toolset=msvc-7.1 --prefix=c:\boost --build-type=complete install<br />
(where c:\boost is the root dir containing all the folders) but still get the error
<br />
C:\boost>bjam toolset=msvc-7.1 variant=debug threading=multi link=shared<br />
C:/boost/tools/build/v2/tools\msvc.jam:734: in configure-really<br />
*** argument error<br />
* rule path.make ( native )<br />
* called with: ( )<br />
* missing argument native<br />
C:/boost/tools/build/v2/util\path.jam:44:see definition of rule 'make' being called<br />
C:/boost/tools/build/v2/tools\msvc.jam:184: in configure<br />
C:/boost/tools/build/v2/tools\msvc.jam:137: in msvc.init<br />
C:/boost/tools/build/v2/build\toolset.jam:38: in toolset.using<br />
C:/boost/tools/build/v2/build\project.jam:862: in using<br />
C:\boost\tools/build/v2\user-config.jam:59: in modules.load<br />
C:/boost/tools/build/v2\build-system.jam:241: in load-config<br />
C:/boost/tools/build/v2\build-system.jam:383: in load-configuration-files<br />
C:/boost/tools/build/v2\build-system.jam:520: in load<br />
C:\boost\tools\build\v2/kernel\modules.jam:283: in import<br />
C:\boost\tools\build\v2\kernel\bootstrap.jam:138: in boost-build<br />
C:\boost\boost-build.jam:16: in module scope<br />
<br />
C:\boost><br />
So when you installed it you moved all the header folders etc. around?
modified on Friday, July 10, 2009 7:49 AM
|
|
|
|
|
minkowski wrote: So when you installed it you moved all the header folders etc. around?
The Boost build script does that.
minkowski wrote: bjam toolset=msvc-7.1 variant=debug threading=multi link=shared
That doesn't match the command-line I shared - but even so, that comamnd-line works for me....
What version of bjam are you using? I'm using version 3.1.16.
PS - to avoid building all the libraries, you might want to use one of the installers from BoostPro[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I've got version bjam
Boost.Build V2 (Milestone 12)
Boost.Jam 03.1.17
|
|
|
|
|
Hmmm - I'm using 3.1.16.
Googling "missing argument native" does indicate some other things to try - if you're using an Express version of MSVC, you may need to explicitly specify the version as an express one using toolset=msvc-9.0express or toolset=msvc-8.0express on the command-line.
Aside from that, I'm a bit stumped - maybe posting to the Boost Users mailing list might help?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi ya,
I've got the enterprise version. Ok I'll try the Boost mailing list.
Thanks for your efforts!
|
|
|
|
|
One last thing - bjam has a --debug-configuration flag that could help you see if things are a little out of kilter.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
i'm working with an activeX CiSliderX control.
what i've to accomplish is:
1). the slider snaps to values which are multiples of 0.25 (DONE BY PROGRAMMING LOGIC FOR MOUSE WHEEL)
(DONE WITH ARROW KEYS) (NOT WORKING WITH :
m_sliderx2.SetMouseWheelStepSize(0.25); )
2). on slider movement, only the values which are a multiple of 0.25 are displayed in the edit box (PROBLEM)
3). on clicking up-down buttons of spin button, the value in the edit box changes in intervals of 0.25 and the new value is depicted on the slider control.(DONE)
4). setting the range of spin control equal to that of slider control.
(NOT WORKING: m_spin1.SetRange32(39, -72); )
UPDATE: DONE THE JOB BY USING SELF PROGRAMMED LOGIC BUT WISH TO KNOW IF SUCH FUNCTIONALITY IS PROVIDED WITH THE CONTROLS THEMSELVES, IN THE FORM OF FUNCTIONS.
|
|
|
|
|
I am trying to follow this:
Creating Threads using the CreateThread() API[^]">
However I am having an issue, My thread is still running even though the main process id done.
What I am trying to achive is a loop to create threads and wait for all the threads to finish the process before I run the same process again.
My Issue is I get a message to say my loop is done, however the thread is still running. Could someone please shed some light.
DWORD WINAPI Thread_1(LPVOID lpParam)
{
int a =0;
char Temp[256];
THREADDATA* pData = (THREADDATA*) lpParam;
UINT nEid = pData->nEditId;
CThreadDemoDlg* pDlg = pData->pObjDlg;
for (a = 0;a<20;a++)
{
_itoa_s(a,Temp,sizeof(Temp),10);
pDlg->SetDlgItemText(nEid,Temp);
ProcessMessages();
}
return 0;
}
DWORD WINAPI Thread_2(LPVOID lpParam)
{
int a =0;
char Temp[256];
THREADDATA* pData = (THREADDATA*) lpParam;
UINT nEid = pData->nEditId;
CThreadDemoDlg* pDlg = pData->pObjDlg;
for (a = 0;a<20;a++)
{
_itoa_s(a+1,Temp,sizeof(Temp),10);
pDlg->SetDlgItemText(nEid,Temp);
Sleep(1000);
ProcessMessages();
}
return 0;
}
TD1->pObjDlg = this;
TD2->pObjDlg = this;
TD1->nEditId = IDC_STATIC1;
TD2->nEditId = IDC_STATIC2;
HANDLE hThread_1;
HANDLE hThread_2;
HANDLE Array_Thread[2];
for (x=0 x<10;x++)
{
hThread_1 = CreateThread(NULL,0,Thread_1,TD1,0,NULL);
if (hThread_1 == NULL)
ExitProcess(-1);
hThread_2 = CreateThread(NULL,0,Thread_2,TD2,0,NULL);
if (hThread_2 == NULL)
ExitProcess(-1);
ProcessMessages();
x++;
_itoa_s(f,Temp,sizeof(Temp),10);
SetDlgItemText(IDC_Main,Temp);
Array_Thread[0]= hThread_1;
Array_Thread[1]= hThread_2;
WaitForMultipleObjects(2,Array_Thread,TRUE,INFINITE);
CloseHandle(hThread_1);
CloseHandle(hThread_2);
}
MessageBox("Done","Information",MB_OKCANCEL);
I get the messagebox, however the The second thread is still running.
|
|
|
|
|
How are you validating that the second thread is running?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
According to the article. The array I pass of handles to the WaitMultipleObjects should take care of that for me.
|
|
|
|
|
Phweeew...
To be honest, there's a lot of things wrong with your code and how you think you should go about multithreading.
Let's try and pin-point a few.
- Use
AfxBeginThread() when building with MFC framework
This must be done to keep the framework happy. Otherwise you'll get into obscure problems that are hard to track down. - Do NOT touch the GUI from a secondary thread
This is very important, especially in MFC since e.g. SetDlgItemText() sends a message to the windows of the control. The difference between sending and posting a message is that sending will block until the message has been processed by the receiving thread. This means that if the thread that "owns" the window doesn't process messages, you'll get a nice little deadlock. - Worker threads doesn't process messages
Your calls to ProcessMessages() are, apart from completely unnecessary, fundamentally wrong. No messages will be sent to your threads. You need to differentiate between so called worker threads that doesn't process messsages and UI-threads. - Your main thread doesn't process messages
After you have called ProcessMessages() , your main thread doesn't process messages any longer. This means that your secondary threads will hang when calling SetDlgItemText() since the receiving window/thread will not consume the message. One way to solve it would be to use ::MsgWaitForMultipleObjects() while waiting for the threads to complete. The correct way would be to return from the function that creates the threads and revert to the window procedure for the main thread. You get into this kind of trouble since you're trying to learn multithreading, but you're using it in a way that contradicts with the reason for having multiple threads since you're still doing things sequentially.
I suspect that the reason why your thread #2 is "still running" when you get the message box is a combination of the above. In other words: your thread #2 hangs because of the call to ::Sleep() since by the time it resumes execution your main thread has stopped processing messages. You should really have a look at the return value from ::WaitForMultipleObjects() .
Some words about what you should do....
Forget about the article you referred to and start here[^]. This is, in my opinion (and a lot of others), the absolute best article for starting out doing multithreading.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thank you for the feedback. I appreciate the honesty. I will check on the article and work my way from there.
thanks a million.
|
|
|
|
|
FISH786 wrote: CThreadDemoDlg* pDlg = pData->pObjDlg;
I smell MFC?
FISH786 wrote: hThread_2 = CreateThread(NULL,0,Thread_2,TD2,0,NULL);
And you're calling CreateThread() . First things first[^]
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: FISH786 wrote:
CThreadDemoDlg* pDlg = pData->pObjDlg;
I smell MFC?
FISH786 wrote:
MessageBox("Done","Information",MB_OKCANCEL);
Calling MessageBox() without a window handle looks very MFC-ish to me, so I guess we are right in our assumptions...
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
So, we can confirm the crime.
But, I didn't go that far. I saw the CThreadDemoDlg* on the first few lines and assumed MFC. After all, the user (while sober) cannot come up with a funky name of that sort on his own.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
hi,
i got some to store the data in tab. i got 1 propertysheet and 3 propertypage to build the tab..
each page i got the data nid to save when the user press the ''ok'' button.
but when i press ''ok'',it only store the data in current page only and not all the 3 pages.
i have read the msdn,it say when u press ''ok'',it will call ''killactive'' function, but when i switch between page 1 to page 2 it already call ''killactive''..zzzz
|
|
|
|
|
Try manually calling UpdateData for each property page when the OK button is clicked.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|