|
Thanks. Well, i need this for a simple test project - i did already something like this UI Thread, so here is nice and simple solution
1. Parameters
struct PARAMS
{
int Val1;
int Val2;
};
2. Thread
DWORD __stdcall Thread(LPVOID lpParam)
{
MSG Message;
while(true)
{
::GetMessage(&Message, NULL, 0, 0);
switch(Message.message)
{
case SOMETHING:
PARAMS *p = (PARAMS*)Message.lParam;
}
}
}
3. Notification
PARAMS *p = new PARAMS;
p->Val1 = ...
::PostThreadMessage(m_dwMyThread, SOMETHING, NULL, (LPARAM)p);
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
csrss wrote:
DWORD __stdcall Thread(LPVOID lpParam)
{
MSG Message;
while(true)
{
::GetMessage(&Message, NULL, 0, 0);
switch(Message.message)
{
case SOMETHING:
PARAMS *p = (PARAMS*)Message.lParam;
}
}
}
The code is doing a GetMessage within an infinite loop, which doesn't look good to me.
I recommend that you have your thread code wait on an event instead, and set that event from outside the thread when the thread needs to get to work.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
I agree, this could end up using a lot of processor time doing nothing.
|
|
|
|
|
GetMessage blocks until there's a message, so it's not bad like using PeekMessage right?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It's not as bad, but it certainly looks clumsy to me. The op needs to just use one of the several ways of thread synchronisation.
Also, will there be a message queue associated with the thread? (note that the OP is calling it from within the worker thread).
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
Hey. You guys are totally right, my way is quite dirty, but you know, sometimes you need some quick code to test things and thats the exact situation. World will never see this :P
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
You don't really need to "pass data to a thread", as all threads in a process have access to the same data.
I typically use a semaphore to signal the worker thread when there's a job to do. The "jobs" are queued in a collection of some sort, and whenever a job is queued, the semaphore's count is incremented, setting its state to signaled. The worker thread waits on the semaphore and pops a job off the queue (don't forget to synchronize access to the collection with a critical section!) and processes it any time the semaphore is signaled.
That's for a single worker thread...If I need a pool of worker threads, I'll use an I/O completion port instead....it does all the above and saves writing alot of thread plumbing code.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hey Mark. I have never actually dealt with semaphores before, mainly events in a regular fashion as well as mutexes and now IOCP
Currently just needed some quick and dirty solution for this test project of mine, because it will land in a recycle bin as soon as i'll figure a couple of things out - just needed to smuggle pair of pointers here and there though Anyways, thanks for a hints - will probably need that in near future.
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
|
Hi,
I got a project which is written in VC++ but while compiling its giving me following error in MS-VC 6.0.
"Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
No configuration specified. Defaulting to MyProject - Win32 Debug.
NMAKE : fatal error U1073: don't know how to make '"e:\win32app\microsoft visual studio\vc98\include\basetsd.h"'
Stop.
Error executing NMAKE."
Please let me know which version of MS-VC6.0 will support this. OR do this project have 3rd party libraries. How to supress this NMAKE errors and complie the code successfully.
SNI
|
|
|
|
|
I don't think you can 'make' a header file; check your project settings.
The best things in life are not things.
|
|
|
|
|
SNI wrote: NMAKE : fatal error U1073: don't know how to make '"e:\win32app\microsoft visual studio\vc98\include\basetsd.h"' Stop. Error executing NMAKE." Please let me know which version of MS-VC6.0 will support this.
Have you verified that the file exists?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Thanks for your reply. I was able to resolve this problem but now I am facing following error
".\Release\MyApp.exe : fatal error LNK1120: 2 unresolved externals
NMAKE : fatal error U1077: 'link.exe' : return code '0x460'
Stop.
Error executing NMAKE.
"
Do I need to change NMAKE file for this?
SNI
|
|
|
|
|
Unresolved externals means you're missing source files or libraries. To fix this, you should add the missing files to the command link of the linker (link.exe).
modified 13-Sep-18 21:01pm.
|
|
|
|
|
I tried to identify what is the problem for giving this kind of error and I found that one of function declared object of dialog class as follows
Dlg_Details *pDet = NULL;
and then it creates instance
pDet = new Details_Dlg();
and here it is giving following err
"error LNK2001: unresolved external symbol "public: __thiscall Dlg_Details::Dlg_Details(class CWnd *)"
(??0Dlg_Details@@QAE@PAVCWnd@@@Z)
.\Release\myapp.exe : fatal error LNK1120: 1 unresolved externals"
when i commented out above line of code (creating instance using new) then appln compiles and link properly.
I tried to go to the detail and found that the constructor of above class is declare as
"Dlg_Details(CWnd* pParent = NULL)" in header file and its implementation as in .cpp file is as follows.
"CDlg_Card_Details::CDlg_Card_Details(CWnd* pParent /*=NULL*/)
: CDialog(Dlg_Details::IDD, pParent)
{
//{{AFX_DATA_INIT(Dlg_Details)
....
....
variables are initialized
}
and I tried to changing its declaration in header file as
Dlg_Details(CWnd* pParent)
but still the problem persist. Can you suggest where this code going wrong during linking.
Regds
SNI
Regds
SNI
SNI
modified on Tuesday, July 12, 2011 8:20 AM
|
|
|
|
|
SNI wrote: NMAKE : fatal error U1077: 'link.exe' : return code '0x460'
See here and here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Hi All,
How to convert Chinese VC++ .rc file to English VC++ .rc file.
I have a VC++ project the dialog resource is in Chinese language
I want to convert the Chinese dialog resource to English dialog resource
how to do it?
Is there any tool?
Pls suggest me.
|
|
|
|
|
You could use Google Translate[^] to do this, but it is not guaranteed to be 100% accurate.
You would need somebody to do this by hand.
|
|
|
|
|
I seriously doubt Google translate is accurate with Chinese (although probably worth a try)... I would just about guess doing it by hand is the only viable option.
|
|
|
|
|
If I were doing it, I'd try Google translate, unless you can find someone fluent in both Chinese and English. If you try an automatic translator, like Google, you will surely need to clean up the results so you don't get hilarious or embarrassing text in your resource strings!
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Hi all
i am encrypt my string using base 64,
but sometimes at the end of string the pad char '=' is occur and the Char for index 62 and 63 also non alphnumric.
i want only alphnumbric values.
so is this possible in this case?
is yes please help me how can i do this?
thanks in advance.
waiting for ur valuable suggestions.
|
|
|
|
|
Base64 is a standard encoding so you will have [A-Z], [a-z], [0-9], +, / and = (complément)
This willl make 26 + 26 + 10 + 2 = 64 characters and = is used as a filling.
If the string is to be used say in an URL, then you must do the appropriate encoding to ensure that the string is valid for that purpose.
You cannot have only alphanumeric characters as they allows only 62 possibilities and Base64 encoding is based on encoding 64 possibilities (6 bits at a time).
Philippe Mori
|
|
|
|
|
As Phillipe mentioned, Base64 uses 64 characters and alphanumerics only contains 62 characters, so if you are determined to use Base 64, there is no good way to confine the results to only 62 alphanumeric characters. Sorry about that.
If you aren't too concerned about using the normal Base64 encoding, then you can devise your own encoding scheme or even substitute some other characters, such as @ , _ , $ , etc. for the ones you don't want. Of course that means you'll need to do the substitution on your own, both when encoding and decoding.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Hi,
Have a look at Base32 Encoding[^]. This is what most 'serial number' algorithms use to ensure printable alphanumeric characters.
Best Wishes,
-David Delaune
|
|
|
|
|
Le@rner wrote: i want only alphnumbric values.
First verify that requirement. It would be a very unusual.
But if you really need that then you can't use base 64 because it includes non-alphanumerics.
You could create your own encoding in base32 using a alpha/numeric for the padding but I doubt it is worth it. You can also use hex which isn't space efficient but is easy to produce.
|
|
|
|