|
can you please elaborate on this
PreTranslateMessage()
where exactly should I put this ?
It is not a method that I can use
can you please explain more please
|
|
|
|
|
Have you tried catching WM_CHAR ?
|
|
|
|
|
Rick York wrote:
Have you tried catching WM_CHAR ?
doesn't work
|
|
|
|
|
Hello,
I want to draw some text into a bitmap image. The image is stored in the memory. I just want to place some text in there. Afterwards it should be processed by a DirectShow pipeline but this doesn't matter here....
I tried a lot with GDI, but it doesn't work so far. Here is my code:
unsigned __int8 pBuffer;
int m_ImageWidth = 1024;
int m_ImageHeight = 1024;<br />
<br />
BITMAP bmp = {0,m_ImageWidth,m_ImageHeight,m_ImageWidth,1,8,pBuffer};<br />
HBITMAP hBMP = CreateBitmapIndirect(&bmp);<br />
HDC hDC_bmp = CreateCompatibleDC(0);<br />
HBITMAP hBMPc = CreateCompatibleBitmap(hDC_bmp,m_ImageWidth,m_ImageHeight);<br />
HGDIOBJ x = SelectObject(hDC_bmp, hBMPc);<br />
<br />
<br />
<br />
HDC hDC_txt = CreateCompatibleDC(0);<br />
int b = BitBlt(hDC_bmp,0,0,200,200,hDC_txt,0,0,BLACKNESS);<br />
<br />
char text_tag[16];<br />
sprintf(text_tag,"0123456789");<br />
RECT rect = {0,0,200,200};<br />
<br />
int a = DrawText(hDC_txt,TEXT(text_tag),1,&rect,DT_LEFT);<br />
<br />
BITMAPINFO bmInfo;<br />
memset(&bmInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));<br />
bmInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);<br />
bmInfo.bmiHeader.biWidth=m_ImageWidth;<br />
bmInfo.bmiHeader.biHeight=m_ImageHeight;<br />
bmInfo.bmiHeader.biPlanes=1;<br />
bmInfo.bmiHeader.biBitCount=24;<br />
<br />
HBITMAP g = CreateDIBitmap(hDC_txt,&bmInfo.bmiHeader,0,0,0,DIB_RGB_COLORS);<br />
<br />
int c = GetObject(g,1024*1024,(void*)pBuffer);
After processing these lines i think I should have the image with the text in the Buffer "pBuffer". But I don't have. Can anyone tell me why and how it works??? I am also open to a different method which just puts text into my bitmap.
Thanks for help
chris
|
|
|
|
|
wookie182 wrote:
HDC hDC_txt = CreateCompatibleDC(0);
int b = BitBlt(hDC_bmp,0,0,200,200,hDC_txt,0,0,BLACKNESS);
this is a problem.
before you Blt to a DC, that DC needs to have a bitmap selected into it.
but, i'm not sure why you need hDC_txt in the first place. you should be able to do a DrawText onto hDC_bmp (after selecting your bitmap into hDC_bmp, of course).
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Well if I do without the hDC_txt it produces the same result. Only 24byte (nonsens) are writen in the Buffer. My new code looked like this
<br />
...<br />
BITMAP bmp = {0,m_ImageWidth,m_ImageHeight,m_ImageWidth,1,8,pBuffer};<br />
HBITMAP hBMP = CreateBitmapIndirect(&bmp);<br />
HDC hDC_bmp = CreateCompatibleDC(0);<br />
HBITMAP hBMPc = CreateCompatibleBitmap(hDC_bmp,m_ImageWidth,m_ImageHeight);<br />
HGDIOBJ x = SelectObject(hDC_bmp, hBMPc);<br />
<br />
char text_tag[16];<br />
sprintf(text_tag,"0123456789");<br />
RECT rect = {0,0,200,200};<br />
<br />
int a = DrawText(hDC_bmp,TEXT(text_tag),1,&rect,DT_LEFT);<br />
<br />
BITMAPINFO bmInfo;<br />
memset(&bmInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));<br />
bmInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);<br />
bmInfo.bmiHeader.biWidth=m_ImageWidth;<br />
bmInfo.bmiHeader.biHeight=m_ImageHeight;<br />
bmInfo.bmiHeader.biPlanes=1;<br />
bmInfo.bmiHeader.biBitCount=8;<br />
<br />
HBITMAP g = CreateDIBitmap(hDC_bmp,&bmInfo.bmiHeader,0,0,0,DIB_RGB_COLORS);<br />
<br />
int c = GetObject(g,1024*1024,(void*)pBuffer__);<br />
I'm very new to this GDI stuff. And I don't exactly know what I'm actually doing. I just want to have text in my bitmap.... so please tolerate some stupid misstakes and questions...
Thanks
Chris
|
|
|
|
|
Ahhh, you almost lost me entirely here "__int8 pBuffer" (that makes no since). Then I glanced at the rest of the code, which almost(!) looks reasonable(?).
wookie182 wrote:
I tried a lot with GDI, but it doesn't work so far.
Sorry, but that is because you do not know what your are doing!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Of course I am NOT using an uninitialized Pointer!!! There is some code before, which allocates memory and puts data to this buffer. I am just new to this GDI stuff and I believe there must be something wrong in these lines....
|
|
|
|
|
Simpilest way:
1) Create a display compatible dc.
2) Create a display compatible bitmap.
3) Select the bitmap into the dc.
4) Draw on the bitmap via the dc.
5) Select the old bitmap into the dc.
6) Release the dc you created.
7) You now have a bitmap with text on it.
Your code is a bit to complicated and you are drawing on 2 different DCs, drawing text is the same as drawing a line or a rectangle. All your drawing must be done on the SAME DC, after all that is where your drawing area is (the bitmap).
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
hi,
can anyone tell me how to show a bitmap or an icon on a button to be used in a dialog window( my application is a SDI app with view class derived from CFormView). i have added a bitmap as a resource.
thanks
aditya
|
|
|
|
|
See this article.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
Aditya Rao wrote:
how to show a bitmap or an icon on a button to be used in a dialog window
Yeap,Here it is :-
This![^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
If WM_PAINT shows up with an hDC of 0 -- does that mean anything?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Peter Weyzen wrote:
If WM_PAINT shows up with an hDC of 0 -- does that mean anything?
It means it's working as expected. As far as I know, WM_PAINT doesn't send an hDC; both wParam an lParam in that message are unused.
Maybe you mean some other message?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Thanks for the help -- I don't know all the details anymore. My boss came in wondering why this was happening...
I didn't have an answer for him...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Hi,
I have written a program. It is doing what I expected but I am not able to detect a window within that program.
Is there any function in win32 or.... which can be used to detect that window?
Please help
Thanks
Preeti9
|
|
|
|
|
|
Thanks for replying...
Here's my code.
// TSCalibrate.cpp : Defines the entry point for the application.
#include "stdafx.h"
#include "CWin32AbsPointAPI.h"
void main ()
{
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
CTouchScreenAPI* pTouch;
HWND hCalWin;
DWORD SYNCRONIZE;
DWORD procId;
HANDLE hProcess;
DWORD dwWaitResult;
pTouch = CTouchScreenAPI::Create();
if (pTouch)
{
if (pTouch->Init())
pTouch->Recalibrate();
else
MessageBox(NULL, "Created touchscreen interface OK, but Init() failed", "Info", MB_OK);
HWND hCalWin = ::FindWindow(pszABSPOINT_WND_CLASS_NAME, NULL);
GetWindowThreadProcessId(hCalWin, &procId); // retrieves the identifier of the thread that created this window.
hProcess = OpenProcess(SYNCHRONIZE, FALSE, procId); //returns a handle to an existing process object
/* SetForegroundWindow(hCalWin);
DWORD AllowSetForegroundWindow(procId);
if (AnyPopup())
{
DisplayWindow(hCalWin);
}
//AnyPopup();
while( true )
{
if( ! IsWindow(hCalWin) )
break; // window is gone;
// Sleep( 1000); // wait a second for window to close
};*/
while (1)
{
dwWaitResult = MsgWaitForMultipleObjects(1, &hProcess, FALSE, 30*1000, QS_ALLINPUT);
if (dwWaitResult == WAIT_OBJECT_0 + 1)
{
MSG xMsg;
while (PeekMessage(&xMsg, NULL, 0, 0, PM_REMOVE))
{
if (xMsg.message == WM_QUIT)
return 1;
TranslateMessage(&xMsg);
DispatchMessage(&xMsg);
}// end of PeekMessage while loop.
}
else if (dwWaitResult == WAIT_TIMEOUT)
{
SendMessage(hCalWin, WM_CLOSE, 0, 0);
//TerminateProcess(hProcess, 0);
break;
}
else dwWaitResult == WAIT_OBJECT_0;
{
//Calibration process completed;
break;
}
}
}
else
{
MessageBox(NULL, "Unable to get pointer to Touchscreen interface", "Info", MB_OK);
}
return 0;
}
This program is running calibration of a machine.
When I run this on command window, it does the calibration and the cursor in command window moves to the next line showing that calibration is done without detection.
I want to detect that window.
Please help
THanks
Preeti9
|
|
|
|
|
Why do you have both main() and WinMain() ?
I'm still not clear as to what window you are wanting to "detect" but the first thing that jumps out at me is that the calls to FindWindow() , GetWindowThreadProcessId() , and OpenProcess() could fail. Why are their return values not being checked? Could that be a reason why the window is not being detected?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
This Program is to detect the window. I associate this program with my calibration process in a machine.Calibration Process is working but it isn't able to detect this window. That's what I am looking for.
I know I need to add few lines in this code. But don't know what to add.
I really don't have any idea how to do this.
Help
Thanks
Preeti9
|
|
|
|
|
Preeti9 wrote:
I know I need to add few lines in this code. But don't know what to add.
DO u Know the Name of the Window to DETECT?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Preeti9 wrote:
This Program is to detect the window.
What window? The window that belongs to your program, or a window that belongs to some other process? What does the "calibration process in a machine" have to do with any of this? Is that related to this mysterious window somehow?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I am using a child frame window to display a view. The child frame window can be resized and when the frame is made smaller than the view scroll bars are appearing and ruining the effect that I want to achieve. The view was created in the resource editor and is of type CFormView. The frame is of type CMDIChildWnd. I have tried a bunch of the following combinations and this is where I am at...
ModifyStyle(WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_THICKFRAME | WS_CAPTION | WS_BORDER | WS_HSCROLL, 0, SWP_NOMOVE);
ModifyStyleEx(WS_EX_STATICEDGE | WS_EX_RIGHTSCROLLBAR, 0, SWP_NOMOVE);
Doesn't work
Any insight???
|
|
|
|
|
raybert wrote:
when the frame is made smaller than the view scroll bars are appearing and ruining the effect that I want to achieve.
What is that effect? You might handle WM_SIZE messages in your view and call SetScrollSizes from the corresponding OnSize function. But what to do exactly might depend on what you are trying to achieve.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|