|
Not sure I understand you too clearly, but you should be processing the WM_SYSCOMMAND message. This is what's sent to your application to tell it to minimize/restore. The WM_SIZE is only sent after the application has been resized.
|
|
|
|
|
if(pMsg->message==WM_SYSCOMMAND)
{
if(pMsg->wParam==SIZE_MINIMIZED||pMsg->lParam==SIZE_MINIMIZED)
{
OnMinimize();
pMsg->lParam=pMsg->wParam=0;
}
if(pMsg->wParam==SIZE_MAXIMIZED||pMsg->lParam==SIZE_MAXIMIZED)
{
OnMaximized();
pMsg->lParam=pMsg->wParam=0;
}
TRIED THIS THING BUT NOT WORKING
payal
|
|
|
|
|
Perhaps you should read the docs about the WM_SYSCOMMAND message. Where are those SIZE_MINIMIZED and SIZE_MAXIMIZED coming from? Infact, all you need to do is search the forums, I know for sure this topic has come up at least 3 times in the last week.
|
|
|
|
|
hi all,
In the OnPaint(...) event i am painting the Dialog as Black Color with every pixel PutPixel(...) with 15 * 15 (Horizontal and Vertical) Dots in entire Screen.
I want to create a Transparent EditControl when ever i am generate a LButton Click event, so that the Dots must be visible from the EditControl what i crated in LButtonDown(...) event.
i am giving the snippet of Code.
//===========================================================================
OnPaint(...) //Back ground color with Putpixel(...)
void CExpDlg::OnPaint()
{
if (IsIconic()) // not necessary wizard code
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else //My code starts here !!!!!!!!!!!!!!!!!!!!!
{
CPaintDC dc(this); // here the black color with Pixel --->
CRect Recto;
GetClientRect(&Recto);
CBrush bgBrush(BLACK_BRUSH);
dc.SelectObject(bgBrush);
dc.Rectangle(Recto);
for(int x = 0; x < Recto.Width(); x += 15)
{
for(int y = 0; y < Recto.Height(); y += 15)
{
dc.SetPixel(x, y, RGB(225, 225, 225));
}
}
CDialog::OnPaint();
} //My code Ends here !!!!!!!!!!!!!!!!!!!!!
}
//==========================================================================
//==========================================================================
second thing is generate the CEdit Control in LButton Event.
void CExpDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
ptr = new CEdit;
ptr->Create(WS_VISIBLE|WS_CHILD|WS_BORDER|WS_TABSTOP|ES_AUTOHSCROLL,CRect (point.x,point.y,point.x +100, point.y +20),this,NULL);
}
//===========================================================================
Now my doubt is The Edit box is created but the Dots that i have drawn in Onpaint must be Trasparent in the Dynamically Created EditBox is not visible.
because Transparent means the back side things must also be visible ????
please help me out.
Uday kiran
|
|
|
|
|
http://www.codeproject.com/editctrl/ctrltrans.asp
gO FOR THIS article a good one for the probs
payal
|
|
|
|
|
|
Hi Gurus,
Does using RegFlushKey automatically close the handle to a new registry key created using RegCreateKeyEx function. Or we have to use RegCloseKey if the handle needs to be closed?
Thanks
C++beginer
|
|
|
|
|
All RegFlushKey() does is write your changes to the registry rather than letting the OS's lazy flusher do the job. It does not close your handle, you have to do that yourself.
|
|
|
|
|
Ok. Thanks for clearing the doubt.
C++beginer
|
|
|
|
|
Hi,
I wanted to create a threaded dialog app however I couldn't find a simple example I could build on. I have now figured out a way to do it mainly based on this article (Unfortunaly you have to download windows speech to get it to run). So I am thinking of using it to create my first article here on code project.
My dialog consists of a start and stop button and an edit control.
The code for the start and stop buttons:
void CSimpleThreadDlg::OnBnClickedOk()<br />
{<br />
int i = 3;<br />
theApp.m_stop = false;<br />
theApp.m_pThread =AfxBeginThread(simThread,(LPVOID)i);<br />
m_start.EnableWindow(0);<br />
}<br />
<br />
void CSimpleThreadDlg::OnBnClickedStop()<br />
{<br />
theApp.m_stop = true;<br />
m_start.EnableWindow(1);<br />
}
And the code for my simple thread:
#include "stdafx.h"<br />
#include "SimpleThread.h"<br />
#include "thread.h"<br />
<br />
unsigned int simThread(LPVOID pParam)<br />
{<br />
unsigned int i = (unsigned int)pParam;<br />
CWnd* pEditControl=theApp.m_pMainWnd ->GetDlgItem (IDC_EDIT1);<br />
CString message;<br />
while(!theApp.m_stop)<br />
{<br />
pEditControl->GetWindowText(message);<br />
message.AppendFormat(_T("\r\nHello World #%i"),i);<br />
pEditControl->SetWindowText(message);<br />
Sleep(500);<br />
i++;<br />
if(i>10)<br />
{<br />
i = 0;<br />
<br />
pEditControl->SetWindowText("");<br />
}<br />
}<br />
PostQuitMessage(0);<br />
return 0;<br />
}
As you can see I disabled the Start button until the Stop button is pressed. If I don't do that it is possible to create multiple theads (Which is a bad thing since I believe it would overwrite the pointer - still leaving the existing thread running. The multiple threads also fight for the dialog.). When the dialog is closed in this situation the debugger reports memory leaks.
Now for my real app I want to kill the thread when the dialog closes...
CSimpleThreadDlg dlg;<br />
m_pMainWnd = &dlg;<br />
INT_PTR nResponse = dlg.DoModal();<br />
if (nResponse == IDOK)<br />
{<br />
}<br />
else if (nResponse == IDCANCEL)<br />
{<br />
}<br />
MSG msg;<br />
theApp.m_stop = true;
return FALSE;<br />
}
However this also has a memory leak, since the application closes before the second thread has a chance to execute...
So what is the correct way around this one? A simple Sleep(10); does the trick since it gives the other thread a chance to run and read m_stop.
Or I figured I could look at PeekMessage to see if the thread had sent the WM_QUIT message. However when debugging I looked at what peak message returned before setting m_stop and it equalled WM_QUIT. (I assumme it was the quit message for the dialog?) So the following loop to check if the thread has finished is not very useful.
<br />
do{ <br />
Sleep(10);<br />
PeekMessage(&msg, dlg, 0, 0, PM_NOREMOVE);<br />
}<br />
while(msg.message != WM_QUIT);
Another question - is the thread a UI thread or a worker thread?
Thanks for your help
Nick
|
|
|
|
|
Use CreateThread or _beginthreadex.
Then wait on the thread handle.
e.g.
theApp.m_pThread = _beginthreadex(...);
...
theApp.m_stop = true;
switch( WaitForSingleObject(theApp.m_pThread, 10000) ) {
case WAIT_TIMEOUT : TerminateThread(); break;
case WAIT_FAILED : ...; break;
case WAIT_OBJECT_0 : ...; break;
}
[EDIT]
From MSDN:
The system maintains a single system message queue and one thread-specific message queue for each graphical user interface (GUI) thread. To avoid the overhead of creating a message queue for non–GUI threads, all threads are created initially without a message queue. The system creates a thread-specific message queue only when the thread makes its first call to one of the User or Windows Graphics Device Interface (GDI) functions.
[/EDIT]
...cmk
Save the whales - collect the whole set ca
|
|
|
|
|
Hi,
Thanks for your help. You got me on the right track. Note AfxBeginThread calls CreateThread. Also that WaitForSingleOptject requires the handle of the thread as below....
switch( WaitForSingleObject(theApp.m_pThread->m_hThread, 10000) ) {<br />
case WAIT_TIMEOUT : TerminateThread(theApp.m_pThread->m_hThread,0); break;
Cheers
Nick
|
|
|
|
|
Hello all
I am writing a Multilingual app, which has to run on
ENG, GERMAN, FRENCH and JAPNEESE os. Now what I have
done is , in one app i made 4 resources and change the
resource accordingly.
But I have one doubt? I heard this can be even achived
by writing 4 resource dll ! I am bit confused now
Which is the better way? I found 4 string table in
one app is the simplest way.
pleas put on your sugg and ideas. thanks
|
|
|
|
|
It really depends on the size of the resources and you future intentions. With resource dll's it is possible to load only the required dll cutting back on memory usage, also if there are any translation problems you only need to redistribute a simgle dll rather than the whole exe. I also find it makes coding a lot easier. When the app starts all it needs to do load the correct dll and store the HINSTANCE, all the resource id's are the same so there's no need mess about with the locale.
If you enumerate the dll's on startup, you can also add further translations without adding code to the main exe.
On the downside, each time you want to change a resource, you have to rebuild them all.
|
|
|
|
|
if you want to change only the strings on the GUI interface for example, no DLL is needed, even though you can use Resource DLLs...
basically, you put all your strings in the Resource String Table. then, you set the language of this string table (in its properties). after that, you copy the string table (and tell VC++ its new target language), and translate the strings into the proper language of the table.
in your application, you have to load the strings (by using CString::Format() or CString::LoadString() for example), and nothing more !
the system will be recognized at the program start, and the correct string table will be used.
|
|
|
|
|
What is the difference between a Device Independent Bitmap and a normal BITMAP? Any specific answers?
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">
|
|
|
|
|
With a DIB, the format of the pixels is independent of a display device. .BMP files are DIBs.
By contrast, a device dependent bitmap is specific to a video device. In theory you could do a bitwise copy to the video buffer and have the bitmap display correction. (In theory; in reality, video devices often use complex layer that precludes actually doing this.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
DIBs have enough information for it to be displayed on any device (printer, screen, etc). That is information such as palettes, RGB/CMYK values, gamma values, etc. A device dependent bitmap *may* be contain enough information to be displayed on another device, but is not required to. The best example of a dependent bitmap is one that uses a palette. Without the palette, the bitmap is at best an array of random bytes for any other use...
--
Mit viel Oktan und frei von Blei, eine Kraftstoff wie Benziiiiiiin!
|
|
|
|
|
hey all,
In my code, the data gets read via USB in a buffer.
i need to save this buffer to a file/ location in my PC (eg., C:/Documents/file1) everytime new data is received.
The file name has to be different everytime new data is read.
how do i do it?
can anyone help with some code snippet or the logic or the functions to be used to achieve this.
Thanks in advance.
|
|
|
|
|
Inorder to make the file name different add curent date and time as suffix for a phrase
say file1_mmddyyyhhmmss
|
|
|
|
|
thanks for the suggestion.
But i need to know how to store the buffer in a file?
|
|
|
|
|
wat is the real problem ?
to read USB or to save the read buffer ?
|
|
|
|
|
i can read usb--no problem in that.
But how do I save the read buffer in to a file of desired location.?
|
|
|
|
|
sorry 4 delay
pBuff = USBReadBuff; // where pBuff and USBReadbuff are char*
CFile TestFile;
CString csFileName = C:\TestFile.txt; // csFileName is the path and name where u want to create the file
TestFile.Open( csFileName, CFile::modeCreate | CFile::modeWrite ))
TestFile.Write( &pBuff, no of bytes )
Is this ok for u
RinuRaj
|
|
|
|
|
thanks very much. I will try now in my program.
Can u also suggest how to have a different file name each time new set of data is received from USB.?
|
|
|
|