|
you can create threads with vb only, too!
Don't try it, just do it!
|
|
|
|
|
That is entirely possible. In C++ you can start threads using the C++ runtime library functions beginthread and beginthreadex. Also available are the Win32 function CreateThread. There is also the MFC Class CWinThread and a global function named something like AfxBeginThread.
There are many articles on MSDN about thread creation in C++ here is just one:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/creating_threads.asp[^]
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
I have a function, from a third party library, that takes a variable number
of arguments, like so
int RealFunc(int var1, ...)
I have a define that I actually call to use this function, like so
#define StubFunc RealFunc
I need to change the define to more of a macro that would allow me to pass
the variable number of arguments to the macro and they gets passed to the
real func call with other functions being called in between, like this
#define StubFunc(int var1, ...) { \
CallOtherFunc() \
RealFunc(var1, ...) // Passing all arguments passed to the macro \
CallOtherFunc2() \
}
Can this be done? Any ideas?
|
|
|
|
|
wouldn't you prefer inline function instead of a macro ?
TOXCCT >>> GEII power
|
|
|
|
|
Inline function would be fine. How can I pass all the parameters to the RealFunc?
|
|
|
|
|
You can't do that in C++. One of the recent C standards (C98 I think) has variadic macros, but that feature hasn't been added to C++ (and it might not be anytime soon, given Stroustrup's and the standards committee's hatred of the preprocessor)
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Pinky, are you pondering what I'm pondering?
I think so Brain, but if we shaved our heads, we'd look like weasels!
|
|
|
|
|
I thought that if done as an inline function, that since the variables are pushed on the stack, and havnt been pop'd off, that there might be a way to "pass" them through. Maybe with some assembly code.
|
|
|
|
|
If your compiler supports variable argument macros on C++ files, you can use the following:
#define StubFunc(arg...) { \
CallOtherFunc() \
RealFunc(arg) // Passing all arguments passed to the macro \
CallOtherFunc2() \
}
The GNU compiler supports this, but not too many other compilers support it.
|
|
|
|
|
If you click on the sliderbar with the mouse, it will move only one pagesize up/down. How can I change this behaviour, that clicking into a slider bar moves it to exactly that position like in WMPs Position-Ctrl?
Is there any simple way to achieve that?
Thanks for any answer
Konrad
|
|
|
|
|
search for some articles here on CodeProject about "Subclassing a control"...
TOXCCT >>> GEII power
|
|
|
|
|
Thanks for your answer. Isn't there any other simple way, than subclassing the control. I think I'm not the first one, who wants to achieve that behaviour. Isn't there a class out there I can use?
Konrad
|
|
|
|
|
Writing some code to allow an app to run correctly with right-to-left languages (e.g., Hewbrew, Arabic.)
For controls that need to be flipped (which is most, but not bitmaps and stuff like that), I add these styles:
WS_EX_LAYOUTRTL<br />
WS_EX_NOINHERITLAYOUT
My first try was to use SetWindowLong to set the style after the window was created.
This works like a champ in Windows 2000 and Windows XP. It doesn't work very well in Windows 98 - there are redraw problems. The windows stays gray until I move or resize, then controls get redrawn. If I do something like pop up a message box, it won't show up unless I open another app, and then switch back to my program!
After reading, I noticed that Microsoft says a lot of controls may not support changing this style at run-time, so I just pass the extended styles into CreateWindowEx . Same problems.
Any ideas? I could post code but it's pretty lengthy. I may play around some more and try to distill this into a small, simple GUI that breaks... but that's going to take some time.
Another note, I am trying this on an actual Windows Me Hebrew machine, as I know Windows Me English, switching to Hebrew, won't work.
I suppose I could do all the mirroring stuff myself, but that will suck. I'd like to avoid it if I can..
Thanks!
"Fish and guests stink in three days." - Benjamin Franlkin
|
|
|
|
|
I have a custom file type for my application. When you click on one of these files it opens my application. I can put the path of the clicked file in the command line that Windows generates to open the application but where does this get passed to? How can I tell my application to open the file once it has happily opened itself?
I am using Visual C++ 6, MFC and a SDI with view/document.
If anyone knows how to do this please let me know as I am going crazy reading through useless MSDN pages.
|
|
|
|
|
check GetCommandLine() API
|
|
|
|
|
Just what I was looking for! Thanks
p
|
|
|
|
|
>> How can I tell my application to open the file once it has happily opened itself?
I find that question is very confusing.
In the MFC SDI document/view architecture any method used to open a file results in the CDocument::Serialize() method being called. What your application does in your override is entirely up to you.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
It was just getting the file path that was an issue. hspc pointed me in thr right direction.
|
|
|
|
|
Hi guys
I'm using
ON_NOTIFY(NM_RCLICK, IDC_LIST1, OnClickList1)
to have control when I click on a CListCtrl (in Report Mode)
Once I'm inside the method, How can I know the item clicked?
void MyClass::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
ItemClicked=???
}
Best Regards
Doc
|
|
|
|
|
Try it.
If you click outside region of Item, the iItem will return -1, else, will return the index of item.
void MyClass::onclickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW * pNMListView = (NM_LISTVIEW*)pNMHDR;
int iItem = ((NM_LISTVIEW*) pNMHDR)->iItem;
}
Enjoy it
Rodrigo Pinho Pereira de Souza
|
|
|
|
|
|
I have an application for which up to 4 instances of it can be fired up.
Now to close an instance of the application another application fires an named event; e.g. closeInstance3.
I use this piece of code for each application to determine what instance it is:
n = __argc;// and __argv
// if n > 1 then instance is specified, otherwise default to IDU 1
if (n > 1)
{
if(n == 2)
{
instanceID = 1;
}
if(n == 3)
{
instanceID = 2;
}
if(n == 4)
{
instanceID = 3;
}
if(n == 5)
{
instanceID = 4;
}
}
else
instanceID = 1; // default
This is because I use the following to start (in this instance 3)
GetStartupInfo(&si[2]);
CreateProcess(NULL, "c:\\Program Files\\Prog.exe 3 3 3", // Name of app to launch; 3 params of 3 = instance 3
NULL, // Default process security attributes
NULL, // Default thread security attributes
FALSE, // Don't inherit handles from the parent
0, // Normal priority
NULL, // Use the same environment as the parent
NULL, // Launch in the current directory
&si[2], // Startup Information
&pi[2]); // Process information stored upon return
The main dialog accesses this variable via the following:
// The instance of this program( range 1 to 4)
extern int instanceID;
I have defined a class member as such:
volatile int m_nProgID;
My question is how do I have the thread which receives events (one of which will be to close this instance of the application) access this variable m_nProgID. I thought volatile would have worked?
Each instance of the program will define (or get a handle) for its close event; i.e. instance 2 will get a handle on event closeInstance2. They use m_nProgID in a switch to get a handle on the event they need to deal with; but it seems that m_nProgID is always 1 in the Thread that handles the events.
Instance 1 closes OK, but default for instanceID is 1. The other instances dont
grahamfff
|
|
|
|
|
Dear all,
To show a tooltip for my control, I used the most basic way; that is, calling the EnableToolTips() and handling the TTN_NEEDTEXT notification. However, my text is too long to be showed in a single line, so I want to break and show it in several lines. Please show me how to do it. I tried setting the maximum tooltip width via message TTM_SETMAXTIPWIDTH, but I failed. It does no effect !!! Thanks so much.
Best regards.
|
|
|
|
|
Hi
i am using CMemFile for MMF operation. i want to ensure that buffer size should be 4K. How to do this.
i think we can specify buffer size in the CreateFileMapping(). Is it correct?
Thanks in advance
ALL THINGS ARE POSSIBLE UNTIL THEY ARE PROVED IMPOSSIBLE-AND EVEN THE IMPOSSIBLE MAY ONLY BE SO,AS OF NOW
|
|
|
|
|
hi
i am trying to make a Client in VC++ for connecting to a Mysql Server
the problem is the connection is not Secure, if someone analyzes the network traffic when i using the Client he can Findout for example my username and password coz they are sent to server in plain text !!!
is there any way for me to make my connection Secure and Encrypted ?
thanx
|
|
|
|
|