|
|
Thank you Chris,
I added
CBitmap* test = new CBitmap;
test->CreateCompatibleBitmap(mem2, dstSize.cx, dstSize.cy);
mem2->SelectObject(test);
and it seems to work.
I still have to fix some color stuff but this is finally the starting point I've been searching for.
Thanks a lot.
|
|
|
|
|
1.)I have a data source that is continously modified, i.e items added, deleted, changed. I used a static global mutex object to actually allow only one thread to modify it. Now I have a list ctrl that shows that data, the refreshing is done in a different thread. Now in that thread:
DeleteAllItems();
for(unsigned int i=0; i<m_aryCall.Count(); i++)
{
..................................................
}
No what if I have a list of 10 elements and I deleted some of them when this thread is running. As the compiler will store the value of m_aryCall.Count() in some temporary variable and when its asks for 10th element, which is not there.
2.)In Modify Data Block a create a thread by new and run it, now the threads are running and the ModifyData is called many times when the previous threads is running. This actually creates memory leak as the thread is not deleting itself.
http://www.priyank.in/
|
|
|
|
|
I am not sure I understand 100% of what you are trying to do, but it seems to me that you have a mumber of threads modifying the data (and using a Global Mutex to make sure they do it one at a time) and a number of threads reading the data.
If that is the case just use the same Mutex for the reading threads also. That way your data is not being modified as another thread is tryting to read it.
|
|
|
|
|
Priyank Bolia wrote:
I used a static global mutex object to actually allow only one thread to modify it
The problem is, you like to directly modify the control from different threads...
You should only modify controls from the main thread (or the thread which created the control)... When you like to directly modify it from an other thread, it comes to unexpected situations like memory leaks or a deadlock of the app...
You should only modify the controls from different threads with the usage of PostMessage...
Communicate from the worker thread(s) with the main thread only with PostMessage and custom defined user messages to provide an save ui access...
like: http://www.codeproject.com/threads/usingworkerthreads.asp
Best regards
|
|
|
|
|
whatz the use of creating static methods??
class x
{
public :
int x;
x()
{
x=10;
}
static void mthod1()
{
cout<<x;
}
="" static="" void="" mthod2()
="" {
="" cout<<x;
="" }
}
void="" main()
{
="" x="" obj;
obj.mthod1();;---="">10
obj.mthod2();---->10
}
both r same..
what'd be the difference?? why its declared ststic?
|
|
|
|
|
Hi,
you don't need an object.
Call x::mthod1();
|
|
|
|
|
that means no need to initiate an object which'd waste (reserve)memory for all other datamembers and functions.. right?
|
|
|
|
|
Yes, it can be really useful in a certain cases. Like for example the CTime object, to retrieve the current time:
CTime t = CTime::GetCurrentTime();
It is also used in the singleton pattern (pattern in which the constructor is private and the only way to obtain your object is through a static method).
Another use of static method inside classes is for callback functions: the statci method don't have an implicit 'this' parameter so it can be used for callback (not like normal member functions).
|
|
|
|
|
Right. But within a static member function you can only address other static class members...
|
|
|
|
|
this take all its sense in languages such as java, where all procedures are necesarilly a part of a class...
so, what to do when you need to call a global function (global by its behavior, but static member of a class by definition) from your code ?
2 choices :
- make an instance of the class that contain the method, then call the method on it... you, this way, have a variable which is allocated but from which you don't need anything...
- have the method static and call it without any instance of the class, just by the class name. this is typically done to put functions together into a logical group name (a namespace or a class). take the exemple of the java class Math ; it contains all the mathematic functions you can would have called, and some constants such as pi, e... all these are static
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
thanks guys .. nice teachers are here!!
|
|
|
|
|
|
|
I want to enumerate the User Account Names for people that actually can log on (i.e. everybody who is listed on the XP logon screen).
Using NetQueryDisplayInformation I also get IIS accounts etc, and with the NetUserEnum's filter parameter, I'm confused
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Hello friends;
I am writting a printer driver for customizing the Document & printer property sheet. I am using Win2K ddk & doing work in the unidrv. I am adding my specification in the sampe code of oemui given in the \ntddk\src\oemdll\ .
It Build successfully but when i click on the "print preferences..." button it shoud shows my "Customize MessageBox" & then it show the Default Document Property sheet (i.e. LayOut , paper Quality).
I want to show only the customize message box not anything default.
Can u please tell me the appropriate answer asap.
Regards
Asim
|
|
|
|
|
I'm trying to select a line of a multiline edit box. I've been using the LineLength function but it doesn't give me the correct number of characters of a line and i wonder why?. This is my code:
void CSubtitlesDlg::SelectLine(int Line)
{
int nLineIndex;
int nLength;
nLineIndex = m_ctrlSubtitlesList.LineIndex(Line-1);
nLength = m_ctrlSubtitlesList.LineLength();
m_ctrlSubtitlesList.SetSel(nLineIndex, nLineIndex + nLength, FALSE);
m_ctrlSubtitlesList.SetFocus();
}
|
|
|
|
|
Hi,
what about
nLength = m_ctrlSubtitlesList.LineLength( nLineIndex ); ?
int LineLength( int nLine = -1 ) const;
nLine
Specifies the character index of a character in the line whose length is to be retrieved. If this parameter is –1, the length of the current line (the line that contains the caret) is returned.
|
|
|
|
|
I am using VC++ 6.0. I want to create an application with one of the functionality of Device Manager. When we connect a usb cam or a scanner its friendly name gets added to Imaging Devices in Device Manager. I would appreciate help in creating an application similar to this but the appplication should make out the difference between the camera abd the scanner.
This is what i have done..
<br />
CString name_class="image";
GUID class_GuidList;<br />
SetupDiClassGuidsFromName(name_class,&class_GuidList,1,&required_size);<br />
dev_info=SetupDiGetClassDevs(&class_GuidList,NULL,handle_win,DIGCF_PRESENT);<br />
ret=SetupDiEnumDeviceInfo(dev_info,(DWORD)i,&DeviceInfoData);<br />
SetupDiGetDeviceRegistryProperty(dev_info,&DeviceInfoData,SPDRP_DEVICEDESC,<br />
&prop_datatype,prop_buffer,100,&req_bufsize);<br />
But the above code lists the scanner also.
Is there any way to make out the differnce between the scanner and the camera?
Regards,
Nripun
|
|
|
|
|
There is an article about doing that on CodeProject.
Don't try it, just do it!
|
|
|
|
|
Alexander M. wrote:
There is an article about doing that on CodeProject
Thanks,
I checked the following article.
http://www.codeproject.com/treectrl/DeviceTree.asp[^]
But i couldnt find any property tat is common to all usbcams and not present/different from scanner.
Regards,
Nripun
|
|
|
|
|
How to highlight multiple chars in different edit control~
What i want to do is to highlight two corresponding characters in two different edit controls?
What i know is before setsel(), i have to set focus to the edit control. So if i do the same thing to highlight the second, the highlighted edit control will definitely lose the focus, and the highlight will disappear~
How to resolve this problem!
|
|
|
|
|
Set the ES_NOHIDESEL property for both the edit controls.
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
|