|
You need some form of Inter-Process Communication to do that, see, for instance, Interprocess Communications[^] at MSDN .
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
The another .exe which is my worker exe will be running on a third party RTOS . Using synchronization it is possible within Win32 and RTOS process. My requirement docs says to stop a RTOS process from UI with a button click and resume it again with same button click (like a toggle) . Things will get more complex if synchronization is used because I am having ~32 threads on RTOS running. ...
Thanks a lot for your nice reply
|
|
|
|
|
pandit84 wrote: The another .exe which is my worker exe will be running on a third party RTOS . Using synchronization it is possible within Win32 and RTOS process. My requirement docs says to stop a RTOS process from UI with a button click and resume it again with same button click (like a toggle) . Things will get more complex if synchronization is used because I am having ~32 threads on RTOS running
What RTOS?! And 32 Threads running on an embedded OS?
You did not give enough information in your first post. See How to ask a question[^], and edit your question to include all relevant information for someone to give you an appropriate response that may be of help.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
I appologies. I thought it like a normal programming scenerio.
My application is actually a industrial software UI application with host 32 threads for a motion controller like a industrial robotics arms.
|
|
|
|
|
So, give the following information:
- Which operating system does your code run on? [Note: This particular board deals primarily with Windows, and may be flavours of UNIX. Other platforms can be supported as long as you're not doing anything propreitary to the OS, because people just may not know about it].
- Are all the 32 threads are running in the context of the same process? If so, just use a thread synchronisation mechanism.
- And what is this "other exe" you're talking about?
Please read the points mentioned in the link I gave you in my earlier reply, and include ALL relevant information if you want someone to help you.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
1. User interface is a Win32 process which communicates with worker layer (running on RTX - RTOS) , using shared memory. UI will be running on windows OS and Worker Layer exe will be running on Interval Zero RTX (Ver 2011). Worker on RTX RTOS will further communicating with hardware ( Industrial firmware components ) to control 32 motion controller devices.
> 32 Threads are in same context i.e. on worker layer side.
>"Other Exe" is nothing but RTX executable i.e worker exe.
Again I would like to say a big "THANKS"
|
|
|
|
|
What I would do is create a program 'work_cmd.exe' for your target platform that only handles the communication with your Win32 UI and nothing else. Your current worker.exe then should be demoted to a thread, and will be spawned from 'work_cmd.exe' . It will still be responsible for spawning the 32 sub-threads, but it needs explicit functions for the purpose of suspending or resuming those threads.
Your 'work_cmd.exe' can then just tell your worker thread to suspend it's dependend threads, and, upon completion, suspend the worker thread itself. To resume, it resumes your worker thread, and then tells it to resume its 'sub-threads'.
Note that my suggestion takes two commands to suspend or resume your threads, as 'work_cmd.exe' doesn't know about the additional threads and delegates their management to your worker thread. This assumes that the additional threads will not automatically be suspended with their parent. Maybe it's possible to spawn them in a way that forces them to be suspended whenever their parent is, but that might depend on your RTOS. (I'm not familiar with RTX)
Note, also, that 'work_cmd.exe' will have to keep running and listening for UI commands.
|
|
|
|
|
So the unique possibility for your GUI to pause/resume the worker thread is by setting a value into the shared memory (and the worker application must poll this value constantly.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
If the other application is running as a Windows service, then the "monitor" application can send a SCM pause command to the Windows service.
|
|
|
|
|
Thanks alot to all . I will try to implement all suggestions.
|
|
|
|
|
Hello everybody !
I wan't to save the bitmap to convert to a single color bitmap (8 pixel / Byte).
I use this way to save to 16 color bitmap. how to convert it to single bitmap ,or how to save it from the device context first ?
HBITMAP GetWindowBitmap(HWND hwnd, LPRECT lpRect)
{
if( !lpRect )
return NULL;
HDC hDC;
HDC hMemDC;
HBITMAP hBitmap = NULL;
HBITMAP hOldBitmap;
if( hwnd == NULL )
hDC = ::GetDC(HWND_DESKTOP);
else
hDC = ::GetWindowDC(hwnd);
if( hDC == NULL )
return NULL;
hMemDC = CreateCompatibleDC(hDC);
hBitmap = CreateCompatibleBitmap(hDC, lpRect->right - lpRect->left,
lpRect->bottom - lpRect->top);
if( hBitmap == NULL)
return NULL;
hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
BitBlt(hMemDC, 0, 0, lpRect->right - lpRect->left,
lpRect->bottom - lpRect->top, hDC, lpRect->left, lpRect->top, SRCCOPY);
SelectObject(hMemDC, hOldBitmap);
DeleteDC(hMemDC);
::ReleaseDC(hwnd, hDC);
return hBitmap;
}
BOOL SaveBitmapToFile(CString strFilePath,HBITMAP hBitmap)
{
HDC hdc = NULL;
FILE* fp = NULL;
LPVOID pBuf = NULL;
BITMAPINFO bmpInfo;
BITMAPFILEHEADER bmpFileHeader;
do{
hdc = ::GetDC(NULL);
ZeroMemory(&bmpInfo,sizeof(BITMAPINFO));
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
GetDIBits(hdc,hBitmap,0,0,NULL,&bmpInfo,DIB_RGB_COLORS);
bmpInfo.bmiHeader.biBitCount = 0x10;
if(bmpInfo.bmiHeader.biSizeImage <= 0)
bmpInfo.bmiHeader.biSizeImage = bmpInfo.bmiHeader.biWidth*abs(bmpInfo.bmiHeader.biHeight)*(bmpInfo.bmiHeader.biBitCount+7)/8;
if((pBuf = malloc(bmpInfo.bmiHeader.biSizeImage)) == NULL)
{
::MessageBox(NULL,_T("Unable to Allocate Bitmap Memory"),_T("Error"),MB_OK|MB_ICONERROR);
return FALSE;
}
bmpInfo.bmiHeader.biCompression = BI_RGB;
GetDIBits(hdc,hBitmap,0,bmpInfo.bmiHeader.biHeight,pBuf,&bmpInfo,DIB_RGB_COLORS);
TRACE(_T("%s\r\n"),strFilePath);
if((fp=fopen(strFilePath.GetBuffer(strFilePath.GetLength()),"wb"))==NULL)
{
::MessageBox(NULL,_T("Unable to Create Bitmap File"),_T("Error"),MB_OK|MB_ICONERROR);
return FALSE;
}
bmpFileHeader.bfReserved1 = 0;
bmpFileHeader.bfReserved2 = 0;
bmpFileHeader.bfSize = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+bmpInfo.bmiHeader.biSizeImage;
bmpFileHeader.bfType = 'MB';
bmpFileHeader.bfOffBits = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
fwrite(&bmpFileHeader,sizeof(BITMAPFILEHEADER),1,fp);
fwrite(&bmpInfo.bmiHeader,sizeof(BITMAPINFOHEADER),1,fp);
fwrite(pBuf,bmpInfo.bmiHeader.biSizeImage,1,fp);
}while(false);
if(hdc)
::ReleaseDC(NULL,hdc);
if(pBuf)
free(pBuf);
if(fp)
fclose(fp);
return TRUE;
}<pre>
Thanks for your reply !
Best regards~~~
|
|
|
|
|
You can do it by following way.
First, you need storage space for color table as being palette entries.
typedef struct tagBITMAPINFO_8BPP
{
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[256];
} BITMAPINFO_8BPP;
I've used above structure for simplicity. You can also allocate it dynamically as much (sizeof(BITMAPINFO) + sizeof(RGBQUAD) * 255) in bytes. In that case, you need to adjust values in BITMAPFILEHEADER and file write operation accordingly.
...
LPVOID pBuf = NULL;
BITMAPINFO_8BPP bmpInfo;
BITMAPFILEHEADER bmpFileHeader;
...
bmpInfo.bmiHeader.biBitCount = 0x08;
...
bmpInfo.bmiHeader.biCompression = BI_RGB;
GetDIBits(hdc, hBitmap, 0, bmpInfo.bmiHeader.biHeight,
pBuf, (BITMAPINFO*)&bmpInfo, DIB_RGB_COLORS);
...
bmpFileHeader.bfReserved1 = 0;
bmpFileHeader.bfReserved2 = 0;
bmpFileHeader.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFO_8BPP) +
bmpInfo.bmiHeader.biSizeImage;
bmpFileHeader.bfType = 'MB';
bmpFileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFO_8BPP);
fwrite(&bmpFileHeader, sizeof(BITMAPFILEHEADER), 1, fp);
fwrite(&bmpInfo.bmiHeader, sizeof(BITMAPINFO_8BPP), 1, fp);
fwrite(pBuf, bmpInfo.bmiHeader.biSizeImage, 1, fp);
...
|
|
|
|
|
thanks !
|
|
|
|
|
There is two different with me:
1、RGBQUAD color table it used 256 count, but is "[1]" before. // why is it?
2、bmpInfo.bmiHeader.biBitCount = 0x01; // here is used 0x01 , means than is a single bitmap .
I use the default RGBQUAD [1], and then set the biBitCount is 0x01, at last use the sam way to write to the file, but the bitmap is invalid.
and then, you used RGBQUAD[256], the bitmap is right , why ?
or this question may said: what's the color table in the bitmap file format ?
(I google this ,but still don't quite understand.)
|
|
|
|
|
bmiColors member of BITMAPINFO is variable sized array. Its size can be zero or more depending on other attributes such as biClrUsed, biBitCount and last parameter of GetDIBits() which can be DIB_PAL_COLORS or DIB_RGB_COLORS.
BITMAPINFOHEADER[^]
Excerpt from above link.
If biCompression equals BI_RGB and the bitmap uses 8 bpp or less, the bitmap has a color table immediatelly following the BITMAPINFOHEADER structure. The color table consists of an array of RGBQUAD values. The size of the array is given by the biClrUsed member. If biClrUsed is zero, the array contains the maximum number of colors for the given bitdepth; that is, 2^biBitCount colors.
In our case, 2 ^ 8 = 256 color table entries exist.
You may also want to look at BITMAPINFO[^].
If bmpInfo.bmiHeader.biBitCount = 0x01; then it is a monochrome bitmap and color table will have two entries (e.g. RGB(0, 0, 0) and RGB(255, 255, 255)).
Color table is array of colors used in the bitmap.
|
|
|
|
|
for example, if all the necessary interfaces for a windowless control is implemented as below,
how to create the control on a dialog, and let it working properly?
class my_ctl : public IOleInPlaceObjectWindowless, public IOleInPlaceSiteWindowless, public IViewObjectEx
{
...
}
Thanks in advance.
BTW, I want it be as simple as possible, just let it work.
|
|
|
|
|
Hi,
I need to draw letters. I have the letter contour points. For normal letter it is easy. But for the letter such as: A, B, D, O, ..
I am using "CreatePolygonRgn" function to draw the letter which has color filled. But I got lines connecting two different contour within one letter.
For example, letter "O", If I fill a color with outside circle and fill none color within inside circle, the background will covered.
Do you have idea how to correctly draw the letter?
Best,
|
|
|
|
|
You need to use transparency (aka Alpha blending) in your colours to allow the background to be seen through.
I must get a clever new signature for 2011.
|
|
|
|
|
Hard to say because your description of the problem is a bit vague, but if i guess right, you could try using CombineRgn[^] ( or CRgn::CombineRgn[^] ) to subtract the holes from your regions.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
Depending on the polygon fill mode, the direction of the polygon outline, clockwise/anti-clockwise, is important as to how GDI handles it, i.e. hole or filled region. You might want to check that out. SetPolyFillMode[^]
|
|
|
|
|
I have a GUI Activex Application . Now I want to get the key press event when focus is on any one of the window control ,i.e.text box , button , listcontrol slider control etc.
Rajesh
|
|
|
|
|
There are lots of ways to solve this...
You could create events for all your controls.
-- In the resource editor right click each control and select add "event handler".
-- then in your code the event handler will appear and you'll be able to control what you want to do with it.
If you need to do that for a lot of controls and the behavior should be the same extend a control class and pre-program it.
You could also capture the WM_KEYDOWN message.
-- Open the class assistant (CTRL+shift+X).
-- messages tab.
-- add the WM_KEYDOWN handler.
You are done.
Hope this helps.
|
|
|
|
|
I use MFC to build a win32 Dynimic-link library. Then I get a bb.dll.I use SetDll.exe to add bb.dll to gogosai.exe.When I
choose A simple DLL project to build the dll,It does not work.When I choose A dll is exports some symbols project to build,It works.
Why???
|
|
|
|
|
Hi,
From your posting it is not clear what you want to achieve. Please be specific and state clearly your actual problem.
Nitheesh George
http://www.simpletools.co.in
|
|
|
|
|
Hi,
After reading your posting 3 times, i think that you wanted to a dll reference to another project, right?. If so, when you create a dll project with some export functions the IDE adds the exporting function as like
extern "C" __declspec(dllexport) void myFunc()
{
}
This tells the C++ complier not to use name mangling. So you can use LoadLbrary to get a pointer to this function in this dll like
HMODULE hMod = LoadLibrary("MyDlLL.dll");
GetProcAddress(hMod, "MyFunc");
this works well you specify extern "C"(Please see MSDN to know more about this).
For a dll that doesn't exports any functions/class don't allow accessing the its functions or classes.
If you don't wish to use the loadLibrary u can do the following steps to add a reference to a dll.
1. Mark the class as exported (__declspec(dllexport) class classA)
1. add the header file of the dll you want to refer.
2. Add the lib file of the dll to the linker options(Additional dependencies) of your project.
3. Make sure that you specify the path to lib correctly.
3. compile.
Hopes this helps.
Nitheesh George
http://www.simpletools.co.in
|
|
|
|
|