|
Why don't you take a look to OnMouseDown and OnMouseUp?
You can look at coordinates of the button or sincronize with OnButtonClick.
Between the time of both mouse messages you have your "Clicking".
For example: I make a drag and drop to move graphical elements in my screen. When left mouse down I check if it hits the surface of any element. If yes... i save the name of the element and set TRUE in a bool "allowDrag". When the left mouse button is released, I search for the element of the saved name, I change its coordenates, and reset to FALSE the allowDrag.
Is something like this what you were asking for?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
I think you need to look at check boxes. You can set them to a button-like style.
So when you click once, it goes in and sends a message.
Click a second time, it goes out and sends another message.
Iain.
|
|
|
|
|
Hi!
I'm writing just in case someone might help me.
I'm to finish a huge program code using MS Visual C++ Express 2005
The problem is that I want to use a win32 function(compatible with VC++ compiler) of the equivalent linux function FCNTL(). These are some my code lines:
Sock_handle_t Server::connect ( const char * name, bool nonblocking ) <br />
{ <br />
struct addrinfo *list = NULL, *first; <br />
<br />
list = getaddrinfo_fromtext ( SOCK_STREAM, IPPROTO_TCP, name ); <br />
if( ! list ) <br />
{ <br />
throw fatal_exception(); <br />
} <br />
<br />
Sock_handle_t sock = create_socket ( AF_INET, SOCK_STREAM, IPPROTO_TCP ); <br />
int fd = sock->fd; <br />
if ( nonblocking ) { <br />
<br />
int flags = fcntl(fd, F_GETFL, 0); <br />
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0 ) return 0; <br />
} <br />
<br />
bool connect_ok = false; <br />
first = list; <br />
while (list) <br />
{ <br />
if( ! ::connect (fd, list->ai_addr, (socklen_t)list->ai_addrlen) || errno == WSAEINPROGRESS ) <br />
{
memcpy ( &sock->address, list->ai_addr, sizeof (sockaddr_in) ); <br />
connect_ok = true; <br />
break; <br />
} <br />
list = list->ai_next; <br />
} <br />
<br />
freeaddrinfo(first); <br />
if(! connect_ok ) <br />
{ <br />
close (fd); <br />
throw fatal_exception(); <br />
} <br />
<br />
return sock; <br />
} --------------------------------------------------------------------
I'm trying to do something like this with those two lines:
int flags = ioctlsocket(fd,F_GETFL,0);
if (ioctlsocket(fd,F_SETFL,reinterpret_cast<u_long*>(flags |_O_NOINHERIT))<0) return 0;
..........but I think it's not ok, any sugestion?
|
|
|
|
|
Here's my cross-platform code for Windows / Linux to set a socket as non-blocking (error checking omitted)
#ifdef WIN32
ulValue = 1;
ioctlsocket (m_hSocket, FIONBIO, &ulValue);
#else
iValue = fcntl (m_hSocket, F_GETFL);
iValue |= O_NONBLOCK;
fcntl (m_hSocket, F_SETFL, iValue);
#endif
Judy
|
|
|
|
|
hi, all,
I wanna know which function is better to use.
Objectif:
i have a FormView in which i use to add some data into a ComboBox before displaying the Form. So i hesitate beteween the OnInitUpdate , PreCreateWindow and WM_CreateWindow.
So which one is the adequate one?
Thx
-- modified at 13:29 Thursday 29th November, 2007
"The Ultimate Limit Is Only Your Imagination.
|
|
|
|
|
If you're going to add items to the ComboBox, you only choice of the three you mention is OnInitialUpdate.
The ComboBox window doesn't exist during PreCreateWindow or during Create. Only after the call to CFormView::OnInitialUpdate does the ComboBox window actually exist (valid hWnd).
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
:-Dprecreatewindow will be better
vijith vijayan
|
|
|
|
|
guys read it carefully
i hav provided odbc connection with an access db1 file
and prepared a ATM project
and used the object m_pSet in all the new classes of dialogs created by me
by passing object of view class as an arguement wen it calls dialog (on button click)
now the problem is
database updation doesnot occur wen we withdraw the money or deposit
it says database updation failed
simply how can v update data frm other class else then view
|
|
|
|
|
paresh_sarjani wrote: and used the object m_pSet
So is your view derived from CRecordView ? Is more than one table involved?
paresh_sarjani wrote: simply how can v update data frm other class else then view
Without a relevant code snippet, it would be impossible to say.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
YEAH
ITS DERIVED FRM CRECORD VIEWWWWW
AND
ONLY 1 TABLE INVOLVEDDDDDD
|
|
|
|
|
Prior to updating the record, have you called the CanUpdate() method?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
yeahhhhhhh
bt it gives error updation failed
|
|
|
|
|
paresh_sarjani wrote: yeahhhhhhh
And what did it returnnnnnnnnnnnnnnnn?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
wat did it return???
i cant get ittttttttt
|
|
|
|
|
Knock off the multiple letters and text speak. Talk like an adult.
|
|
|
|
|
paresh_sarjani wrote: i cant get ittttttttt
Why not?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
ROTFLMA
So you are either busy the past while or have given up for the time being... I feel you brother
|
|
|
|
|
no dudeeeeeee
if u guysss dont help me den i'll find out sum other wayyyy
bt pls help me if u can
|
|
|
|
|
Hello,
Currently, I am using LoadImage() to get a handle to an icon that is a resource in my Win32 Application project (using VS2005). Now though, I've added more icons to this icon resource...I now have 3 icons within it, each of 16x16 size, but of different colors (a normal, highlighted and disabled icon).
It looks like LoadImage() is the preferred function to use, but I can't figure out how to extract an icon with a specific index from my icon resource.
Functions like ExtractIcon(), etc. need to be supplied with a path to an .exe, or .ico. I just have it as a resource in my app (ie: IDM_RESET).
Any ideas on the best way to get the icon I want?
Thanks,
|
|
|
|
|
Gunn317 wrote: Any ideas on the best way to get the icon I want?
You mean besides reading the documentation[^]? No I always have to resort to reading the documentation, is there another way?
|
|
|
|
|
The original screen is in MemDC
I copy MemDC to MemDC2 first, then draw cross lines in MemDC2,
at last copy MemDC2 to real dc.
Why is the screen still blink when moving the mouse?
The code are in OnMouseMove
<br />
CClientDC dc(this);<br />
<br />
int OldDC=dc.SaveDC();<br />
dc.SetMapMode(MM_ANISOTROPIC);<br />
dc.SetWindowExt(m_WinXExt,-m_WinYExtTri);<br />
dc.SetViewportExt(rt.Width()-m_LeftMargin-m_DeltaViewXExt,int(rt.Height()*0.5f)-m_DescH);<br />
dc.SetWindowOrg(0,0);<br />
dc.SetViewportOrg(m_LeftMargin,int(rt.Height()*0.5f));<br />
<br />
CPoint pt(point);<br />
dc.DPtoLP(&pt);<br />
pt.x=pt.x/m_UnitsPerHemline*m_UnitsPerHemline+int(m_UnitsPerHemline*0.5f);<br />
UINT n=pt.x/m_UnitsPerHemline;<br />
if (n>=m_CntDispGrp) return;<br />
<br />
dc.LPtoDP(&pt);<br />
dc.RestoreDC(OldDC);<br />
<br />
n=m_CntCandidateGrp-m_CntDispGrp+n;<br />
m_pRs->Move(n,_variant_t(long(adBookmarkFirst)));<br />
COleDateTime OleDT=m_pRs->GetCollect("时刻");<br />
m_MemDC2.BitBlt(0,0,rt.Width(),rt.Height(),&m_MemDC,0,0,SRCCOPY);<br />
m_MemDC2.SelectObject(&m_WPen);<br />
m_MemDC2.SetROP2(R2_XORPEN);<br />
m_MemDC2.MoveTo(m_LeftMargin,point.y);<br />
m_MemDC2.LineTo(rt.Width(),point.y);<br />
m_MemDC2.MoveTo(pt.x,0);<br />
m_MemDC2.LineTo(pt.x,rt.Height()-m_BottomMargin);<br />
m_MemDC2.SetROP2(R2_COPYPEN);<br />
dc.BitBlt(0,0,rt.Width(),rt.Height(),&m_MemDC2,0,0,SRCCOPY);<br />
CBrush BBr(RGB(0,0,255));<br />
CString s=OleDT.Format();<br />
CRect RtText(0,0,0,0);<br />
m_MemDC2.SetBkMode(TRANSPARENT);<br />
m_MemDC2.SetTextColor(RGB(255,0,0));<br />
m_MemDC2.SelectObject(&m_RPen);<br />
m_MemDC2.DrawText(s,&RtText,DT_CALCRECT);<br />
RtText.InflateRect(2,0,2,0);<br />
RtText.OffsetRect(pt.x-int(RtText.Width()*0.5f),int(rt.Height()-m_BottomMargin));<br />
if (RtText.right>rt.Width()) {<br />
RtText.OffsetRect(rt.Width()-RtText.right,0);<br />
}<br />
RtText.bottom=rt.Height();<br />
RtText.top=RtText.bottom-m_BottomMargin+1;<br />
m_MemDC2.FillRect(&RtText,&BBr);<br />
m_MemDC2.DrawText(s,&RtText,DT_CENTER|DT_VCENTER|DT_SINGLELINE);<br />
m_MemDC2.MoveTo(RtText.TopLeft());<br />
m_MemDC2.LineTo(RtText.left,RtText.bottom);<br />
m_MemDC2.MoveTo(RtText.right,RtText.top);<br />
m_MemDC2.LineTo(RtText.BottomRight());<br />
<br />
float f;<br />
if (pt.y<int(rt.Height()*0.5f)) {<br />
f=m_DispMinVolt+(rt.Height()*0.5f-pt.y)*(m_DispMaxVolt-m_DispMinVolt)/(rt.Height()*0.5f-m_DescH);<br />
s.Format("%.2f",f);<br />
RtText.SetRect(0,0,0,0);<br />
m_MemDC2.DrawText(s,&RtText,DT_CALCRECT);<br />
RtText.InflateRect(0,1,0,1);<br />
RtText.right=m_LeftMargin;<br />
RtText.OffsetRect(0,pt.y-int(RtText.Height()*0.5f));<br />
if (RtText.top<0) {<br />
RtText.OffsetRect(0,-RtText.top);<br />
}<br />
m_MemDC2.FillRect(&RtText,&BBr);<br />
m_MemDC2.DrawText(s,&RtText,DT_RIGHT|DT_VCENTER|DT_SINGLELINE);<br />
m_MemDC2.MoveTo(RtText.TopLeft());<br />
m_MemDC2.LineTo(RtText.right,RtText.top);<br />
m_MemDC2.MoveTo(RtText.left,RtText.bottom);<br />
m_MemDC2.LineTo(RtText.BottomRight());<br />
} else if (pt.y<rt.Height()-int(m_BottomMargin)) {<br />
if (m_AN_ZJY==1) {<br />
f=m_DispMinAN+(rt.Height()-m_BottomMargin-pt.y)*(m_DispMaxAN-m_DispMinAN)/(rt.Height()*0.5f-m_BottomMargin-m_DescH);<br />
s.Format("%.2f",f);<br />
RtText.SetRect(0,0,0,0);<br />
m_MemDC2.DrawText(s,&RtText,DT_CALCRECT);<br />
RtText.InflateRect(0,1,0,1);<br />
RtText.right=m_LeftMargin;<br />
RtText.OffsetRect(0,pt.y-int(RtText.Height()*0.5f));<br />
m_MemDC2.FillRect(&RtText,&BBr);<br />
m_MemDC2.DrawText(s,&RtText,DT_RIGHT|DT_VCENTER|DT_SINGLELINE);<br />
m_MemDC2.MoveTo(RtText.TopLeft());<br />
m_MemDC2.LineTo(RtText.right,RtText.top);<br />
m_MemDC2.MoveTo(RtText.left,RtText.bottom);<br />
m_MemDC2.LineTo(RtText.BottomRight());<br />
} else if (m_AN_ZJY==2) {<br />
f=m_DispMinZJY+(rt.Height()-m_BottomMargin-pt.y)*(m_DispMaxZJY-m_DispMinZJY)/(rt.Height()*0.5f-m_BottomMargin-m_DescH);<br />
s.Format("%.2f",f);<br />
RtText.SetRect(0,0,0,0);<br />
m_MemDC2.DrawText(s,&RtText,DT_CALCRECT);<br />
RtText.InflateRect(0,1,0,1);<br />
RtText.right=m_LeftMargin;<br />
RtText.OffsetRect(0,pt.y-int(RtText.Height()*0.5f));<br />
m_MemDC2.FillRect(&RtText,&BBr);<br />
m_MemDC2.DrawText(s,&RtText,DT_RIGHT|DT_VCENTER|DT_SINGLELINE);<br />
m_MemDC2.MoveTo(RtText.TopLeft());<br />
m_MemDC2.LineTo(RtText.right,RtText.top);<br />
m_MemDC2.MoveTo(RtText.left,RtText.bottom);<br />
m_MemDC2.LineTo(RtText.BottomRight());<br />
}<br />
}<br />
dc.BitBlt(0,0,rt.Width(),rt.Height(),&m_MemDC2,0,0,SRCCOPY);<br />
<br />
|
|
|
|
|
OnMouseMove is a message handler, you need to read the MSDN understand the messaging. The messages come out of the queue and get handled...
Drawing has to be done in OnPaint().
Greetings from Germany
|
|
|
|
|
OMG , I didn't realized about it. I thought he was calling the OnPaint when mouse moved. I need to buy me glasses :P
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
When moving the mouse, WM_PAINT won't be sent, is it sure?
I think it is, so I draw in OnMouseMove, just like scratch in the client when press the left button and dragging in mspaint.
|
|
|
|
|