|
If you erase an element from a vector the elements after the deleted element are moved to fill the space. A vector 's memory never gets smaller unless you use the following trick:
vector<int> copy(source);
source.swap(copy);
Steve
|
|
|
|
|
I tried ~WS_THICK_FRAME in precreate window.
Maximize box is disabled but when i double click on title bar it always restores
how to prevent this???
Problem is solved......
I solved using WM_NCLBUTTONDBLCLK any other solution.
|
|
|
|
|
Override OnNcLButtonDblClk().
Manish Rastogi
|
|
|
|
|
I'm new to c++ and this forum, so please...
I want to convert one type(int/float/double, can be 8/16/32/64bits), which is unknow when compiling, to another type, which is also unknow at compile time, in some function. One way is to use a vitual function and override that function with different arugment types. It's a heavy function with a lot of coding, so I want to search some other options.
I'm wondering if there is a solution so that I only need to write one conversion function which can take care of whatever input/output types.
Here are some pseudo codes which I'm not sure if they can be somehow realized. Hope it wouldn't confuse you.
define type T*;
Convert( T* in, T* out)
{
for_each_datum_in
{ *in=(type of out)*out;
}
}
//call the function here
Convert( TypeOfIn * in, TypeOfOut * out);
now here am i
|
|
|
|
|
Strictly speaking you can't do what you've asked about in ordinary C++. Only using .NET reflection, but the chances are that the set of types is not really 'unknown' at compile time it's just that you don't want to have to write much or any new code when you change that set?
If that's true you have a chance. Consider using templates e.g.
<br />
template< typename Ti, typename To ><br />
Convert( Ti* pIn, To* pOut )<br />
{<br />
}<br />
In the end you'll probably have to provide lots of type specific template overrides like
<br />
Convert( double* pIn, char* pOut )<br />
{<br />
}<br />
which is not much better than where you started out.
If you've hit this problem and most of us have then you probably need to go back and look at your design with a 'what is this really try to achieve' hat on
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Is there some reason a template function won't work?
|
|
|
|
|
Must admit that I am not sure if I understood your problem. But according to I interpreted,
when you talk about converting types, you imply the concept of "casting" (Casting one data type to be another). With respect to your given pseudocode, I guess you want the type pointed by "out" to be treated as type "in" so that the assignment can work nicely. Thus you want to cast the type pointed by "out" to be as type pointed by "in".
If that understanding is true ...
You need to delve in to understanding how "type casting" works in C++. A nice tutorial -
http://www.cplusplus.com/doc/tutorial/typecasting.html
I like it as they quickly goes into how type casting with classes/structs and pointer to those needs to be carefull than for basic types.
Also for completeness, even in the case of template, it will eventually boils down to type casting as soon as the type is provided for the templates. So if you have defined two template types being them as type independent, during the runtime they are associated with provided types, hence the game boils down to type conversion between those two types.
So understanding the "type casting" will enlighten you about how to do it and if done will it be meaning full.
And for the conclusion, you will see that even though it is not a runtime error some casting will not be meaningfull or result in an wanted manner. There is no such freedom as converting ANY type to ANY type. Its not meaningfully possible (such as converting a student info class to a integer number).
Hope it can help.
Regards
|
|
|
|
|
Just in case I wan't clear about it - I agree with Matthew Faithfull.
And interestingly enough, quick Googling shows that there seems to be few implementation of Reflection in C++.
http://www.extreme.indiana.edu/reflcpp/
Hey, Its C++, It can do everything ...
|
|
|
|
|
I am developing an app which will fetch addresses from the GAL. I need the email address of the users. I get those in the exchnage format (Electronic mail format)
for eg. /c=US/a=att/p=Microsoft/o=Finance/ou=Purchasing/s=Furthur/g=Joe
and need those in
I am using Exchange SDk to fetch the contacts from GAL.
for e.g : xyz@fgh.com
"A winner is not one who never fails...but the one who never quits"
|
|
|
|
|
Hi for all
I've created a program that triggers some threads.
I don't get to use the syncronization. Some threads are triggered before others.
I created a class called ResourceObject. This is a simple class with a boolean value and a CRITICAL_SECTION value:
<br />
ResourceObject::ResourceObject()<br />
{<br />
m_bLocked = false;<br />
InitializeCriticalSection(&m_ResourceSection);<br />
}<br />
ResourceObject::~ResourceObject()<br />
{<br />
DeleteCriticalSection(&m_ResourceSection);<br />
}<br />
<br />
void ResourceObject::LockResource(unsigned int uiTimeToSleep)<br />
{<br />
EnterCriticalSection(&m_ResourceSection);<br />
m_bLocked = true;<br />
Sleep(uiTimeToSleep);<br />
LeaveCriticalSection(&m_ResourceSection);<br />
}<br />
<br />
void ResourceObject::ReleaseResource()<br />
{<br />
EnterCriticalSection(&m_ResourceSection);<br />
if(m_bLocked)m_bLocked = false;<br />
LeaveCriticalSection(&m_ResourceSection);<br />
}<br />
In another class I have this struct that have a pointer to a ResourceObject
<br />
typedef struct LineText<br />
{<br />
FloatText * Line;<br />
bool bShow;<br />
float fTimeWait;<br />
ResourceObject * resource;<br />
}TextLine;<br />
In the same class I have the following codes:
- the first is how I create a thread;
<br />
idThread[m_iLineCount] = CreateThread(NULL, 0, Helper::TextThread, (void*)&Lines[m_iLineCount], CREATE_SUSPENDED, NULL);<br />
- the second is the thread:
<br />
DWORD WINAPI Helper::TextThread(void * vData)<br />
{<br />
LineText * temp = (LineText *)vData;<br />
temp->resource->LockResource(2000);<br />
temp->bShow = true;<br />
temp->resource->ReleaseResource();<br />
return 0;<br />
}<br />
- the third is when I Resume the threads and show some text;
<br />
void Helper::ShowImages()<br />
{<br />
for(int i = 0 ; i < m_iLineCount ; i++)<br />
{<br />
ResumeThread(idThread[i]);<br />
if(Lines[i].bShow)Lines[i].Line->PrintText();<br />
}<br />
}<br />
The threads must have to follow the sequence in that they are resumed, but they don't. Even the first thread is started with the resource, it is not the first to show the text.
Anyone can help me to solve this problem?
Thanks
|
|
|
|
|
If you want multiple threads to pass through a single function in predetermined order you're going to need a master thread to manage them and each one will have to wait to be signalled. I would add an Event to your one-per-thread structure, have each worker wait on its event and then have the main thread signal each event and wait for it to be reset by the signalled thread before singalling the next one. Have the worker reset its event after it has executed your controlled function. I can't see why you'd want to do this as it seems to negate any real benefit of threading but it's your project
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Not sure I understand, you want to use multiple threads to perform sequential operations?
|
|
|
|
|
More or less.
Like you've seen in my code, I have a thread that receives a structure. I have about 10 structures that have different values of text. And I need to show these texts in some moment. At the moment I need to show these values sequentially, but in any other time I would need to show these texts in any other sequence. Just like that, I create the ResourceObject class. I have a pointer to an object of this type in my structs. The first started thread access this object and the others wait.
I called the threads sequentially thinking that the calling order have been respected, with one thread at time access the resource and release it.
|
|
|
|
|
Alex Cutovoi wrote: More or less.
What? You don't know? How are we supposed to help you if you can't specify exactly what your requirements are.
Alex Cutovoi wrote: I need to show these texts in some moment.
I have no idea what that means. I am not familiar with "Moment Based Processing".
Look the bottom line is that trying to use multiple threads to execute sequential operations is like putting a square peg in a round hole. It doesn't seem your approach is the appropriate solution to your problem, whatever that is.
|
|
|
|
|
Look, I'll explain better.
What I really want is the threads access the resource in the order that they started. What that is not occur at the moment.
Example, I have 4 thread(thread1, thread2, thread3, thread4).
If I start the threads in a sequence like thread4, thread2, thread1, thread3, the threads must access the resource in this sequence. Even with the CriticalSection, this is not occur. The threads access the resource in an arbitrary order. The only thing that works is that the resource is accessed for one thread at a time.
I've tried to put a mutex to guarantee this type of access but I didn't get the expected results.
This is EXACTLY what I want.
|
|
|
|
|
Alex Cutovoi wrote: Look, I'll explain better.
Alex Cutovoi wrote: This is EXACTLY what I want.
No that is not an explanation of the "requirements". What "you want" has nothing to do with what "the requirements" are. Do you have requirements for sequential operations? Yes or no? If yes then threads are not an appropriate solution even if you "want" to use threads.
Note: You should never "want" to use threads. They should be used as a last resort, only to satisfy specific requirements.
|
|
|
|
|
You're right, but unhapilly I solved my problem.
Thanks
|
|
|
|
|
Please, can anyone provide me help on this. I am creating an application where I need to create multiple image controls (or maybe a GDI+ graphics on that control) with transparent background on CFormView. These controls will provide user the ability to move, resize or select the control. I am stuck on this from long time and not able to find any solution. I will be very greatful if someone can provide me help on this.
Thanks,
Selvaraj
|
|
|
|
|
kcselvaraj wrote: I am stuck on this from long time and not able to find any solution.
Can you be more specific about what part(s) you're stuck on?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
I am writing an application where I have CFormView as a "Preview Image". I want to create a windowless/traparent control on which I can use TextBox or GDI+ drawing and user can select, move and resize the control. User can select a graphic from list of graphics like ellips, circle, rectangle or checkmark and place it on "Preview Image". I want to know how can I create such a control?
I will be really greatful to you if you can help me out with this.
Selvaraj
-- modified at 6:31 Wednesday 4th July, 2007
|
|
|
|
|
I am creating a library that is using a library that has a function implemented called xlAutoOpen. I wrote a function called xlAutoOpen, how do I in my .def file tell the linker to reference the one I wrote?
I am getting errors like these because the linker isn't sure which
function I am referencing...
1>curve.def : warning LNK4022: cannot find unique match for symbol
'xlAutoOpen'
1>curve.def : warning LNK4002: "int __cdecl xlAutoOpen(void)" (?
xlAutoOpen@@YAHXZ) defined in .\release\Generic.obj
1>curve.def : warning LNK4002: _xlAutoOpen@0 defined in .
\Univswap.lib
1>curve.def : warning LNK4002: _xlAutoOpen@0 defined in .\Univyld.lib
1>curve.def : error LNK2001: unresolved external symbol xlAutoOpen
These functions are essential because they are the required functions
for this interface I am using.
Thanks
|
|
|
|
|
This is just a guess, but if your xlAutoOpen file is written in c++, it will have a decorated name (to cope with different parameters)
I suspect all you'll need is to declare it as:
extern "C"
{
XXXX xlAutoOpen (....)
}
or the like.
While that's hardly a full solution, I hope it points you in the right direction.
Iain.
|
|
|
|
|
Hey all,
I have several projects that I want to complete that involve USB devices. I was wondering if there is any generic way to grab the output and input to any USB device.
I'm not looking for anything too clean, just something that works for the moment, as I will spend time adjusting the method to my various projects.
At any rate, is there a generic way to access the output and input of any USB device in windows? (or even just grab the output?)
thanks,
- legit
legit-tech.net
|
|
|
|
|
legit wrote: I was wondering if there is any generic way to grab the output and input to any USB device.
No, there isn't.
Anyway, try to post your question to the Hardware forum.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi,
Please provide the links / documents for Microsoft Windows NT / XP / Vista arhitecture.
Anything regarding the MS Windows programming using C++ language highly appreciated.
Thanks & Regards,
Neeraj
|
|
|
|