summaryrefslogtreecommitdiffabout
path: root/PumpKINDlg.cpp
Unidiff
Diffstat (limited to 'PumpKINDlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--PumpKINDlg.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/PumpKINDlg.cpp b/PumpKINDlg.cpp
index 0b3bf41..fc24596 100644
--- a/PumpKINDlg.cpp
+++ b/PumpKINDlg.cpp
@@ -282,96 +282,97 @@ void CPumpKINDlg::OnPaint()
282 if (IsIconic()) 282 if (IsIconic())
283 { 283 {
284 CPaintDC dc(this); // device context for painting 284 CPaintDC dc(this); // device context for painting
285 285
286 SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); 286 SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
287 287
288 // Center icon in client rectangle 288 // Center icon in client rectangle
289 int cxIcon = GetSystemMetrics(SM_CXICON); 289 int cxIcon = GetSystemMetrics(SM_CXICON);
290 int cyIcon = GetSystemMetrics(SM_CYICON); 290 int cyIcon = GetSystemMetrics(SM_CYICON);
291 CRect rect; 291 CRect rect;
292 GetClientRect(&rect); 292 GetClientRect(&rect);
293 int x = (rect.Width() - cxIcon + 1) / 2; 293 int x = (rect.Width() - cxIcon + 1) / 2;
294 int y = (rect.Height() - cyIcon + 1) / 2; 294 int y = (rect.Height() - cyIcon + 1) / 2;
295 295
296 // Draw the icon 296 // Draw the icon
297 dc.DrawIcon(x, y, m_hIcon); 297 dc.DrawIcon(x, y, m_hIcon);
298 } 298 }
299 else 299 else
300 { 300 {
301 CPaintDC pDC(this); 301 CPaintDC pDC(this);
302 CDC bmpDC; 302 CDC bmpDC;
303 bmpDC.CreateCompatibleDC(&pDC); 303 bmpDC.CreateCompatibleDC(&pDC);
304 bmpDC.SelectObject(&m_bmpBack); 304 bmpDC.SelectObject(&m_bmpBack);
305 CRect rc; 305 CRect rc;
306 GetClientRect(&rc); 306 GetClientRect(&rc);
307 for(int x=-m_bitmapBack.bmWidth*2/4;x<rc.Width();x+=m_bitmapBack.bmWidth) 307 for(int x=-m_bitmapBack.bmWidth*2/4;x<rc.Width();x+=m_bitmapBack.bmWidth)
308 for(int y=-m_bitmapBack.bmHeight*2/4;y<rc.Height();y+=m_bitmapBack.bmHeight) 308 for(int y=-m_bitmapBack.bmHeight*2/4;y<rc.Height();y+=m_bitmapBack.bmHeight)
309 pDC.BitBlt(x,y,m_bitmapBack.bmWidth,m_bitmapBack.bmHeight,&bmpDC,0,0,SRCCOPY); 309 pDC.BitBlt(x,y,m_bitmapBack.bmWidth,m_bitmapBack.bmHeight,&bmpDC,0,0,SRCCOPY);
310 bmpDC.DeleteDC(); 310 bmpDC.DeleteDC();
311 CDialog::OnPaint(); 311 CDialog::OnPaint();
312 } 312 }
313} 313}
314 314
315// The system calls this to obtain the cursor to display while the user drags 315// The system calls this to obtain the cursor to display while the user drags
316// the minimized window. 316// the minimized window.
317HCURSOR CPumpKINDlg::OnQueryDragIcon() 317HCURSOR CPumpKINDlg::OnQueryDragIcon()
318{ 318{
319 return (HCURSOR) m_hIcon; 319 return (HCURSOR) m_hIcon;
320} 320}
321 321
322int CPumpKINDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 322int CPumpKINDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
323{ 323{
324 if (CDialog::OnCreate(lpCreateStruct) == -1) 324 if (CDialog::OnCreate(lpCreateStruct) == -1)
325 return -1; 325 return -1;
326 326
327 m_Listener.m_Daddy=this; 327 m_Listener.m_Daddy=this;
328 if(!m_Listener.Create(m_ListenPort,SOCK_DGRAM)){ 328 if(!m_Listener.Create(m_ListenPort,SOCK_DGRAM)){
329 TRACE0("Failed to create socket\n"); 329 TRACE0("Failed to create socket\n");
330 AfxMessageBox(IDS_BOX_CANTBIND,MB_OK|MB_ICONEXCLAMATION);
330 return -1; 331 return -1;
331 } 332 }
332 333
333 if(!m_Trayer->Create(NULL,"PumpKIN TrayIcon",WS_CHILD,CRect(0,0,0,0),this,0)){ 334 if(!m_Trayer->Create(NULL,"PumpKIN TrayIcon",WS_CHILD,CRect(0,0,0,0),this,0)){
334 TRACE0("Failed to create trayer\n"); 335 TRACE0("Failed to create trayer\n");
335 return -1; 336 return -1;
336 } 337 }
337 338
338NOTIFYICONDATA nid; 339NOTIFYICONDATA nid;
339 memset(&nid,0,sizeof(nid)); 340 memset(&nid,0,sizeof(nid));
340 nid.cbSize=sizeof(nid); 341 nid.cbSize=sizeof(nid);
341 nid.hWnd=m_Trayer->m_hWnd; 342 nid.hWnd=m_Trayer->m_hWnd;
342 nid.uID=IDC_TRAYICON; 343 nid.uID=IDC_TRAYICON;
343 nid.uFlags=NIF_MESSAGE|NIF_ICON|NIF_TIP; 344 nid.uFlags=NIF_MESSAGE|NIF_ICON|NIF_TIP;
344 nid.uCallbackMessage=WM_TRAYICON; 345 nid.uCallbackMessage=WM_TRAYICON;
345 nid.hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME); 346 nid.hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
346 // *** Load from resource 347 // *** Load from resource
347 strcpy(nid.szTip,"PumpKIN"); 348 strcpy(nid.szTip,"PumpKIN");
348 VERIFY(Shell_NotifyIcon(NIM_ADD,&nid)); 349 VERIFY(Shell_NotifyIcon(NIM_ADD,&nid));
349 350
350 return 0; 351 return 0;
351} 352}
352 353
353void CListenSocket::OnReceive(int nErrorCode) 354void CListenSocket::OnReceive(int nErrorCode)
354{ 355{
355 ASSERT(m_Daddy); 356 ASSERT(m_Daddy);
356 if(nErrorCode){ 357 if(nErrorCode){
357 m_Daddy->LogLine(IDS_LOG_LISTENRECEIVEERROR); 358 m_Daddy->LogLine(IDS_LOG_LISTENRECEIVEERROR);
358 return; 359 return;
359 } 360 }
360DWORD fionread = 0; 361DWORD fionread = 0;
361 VERIFY(IOCtl(FIONREAD,&fionread));// *** Do some checking on the value acquired 362 VERIFY(IOCtl(FIONREAD,&fionread));// *** Do some checking on the value acquired
362tftp *tftpRQ = tftp::Allocate(fionread); 363tftp *tftpRQ = tftp::Allocate(fionread);
363 ASSERT(tftpRQ); 364 ASSERT(tftpRQ);
364SOCKADDR_IN sin; 365SOCKADDR_IN sin;
365 if(!tftpRQ->Receive(this,fionread,&sin)){ 366 if(!tftpRQ->Receive(this,fionread,&sin)){
366 m_Daddy->LogLine(IDS_LOG_LISTENACCEPTERROR); 367 m_Daddy->LogLine(IDS_LOG_LISTENACCEPTERROR);
367 delete tftpRQ; 368 delete tftpRQ;
368 return; 369 return;
369 } 370 }
370 #ifndefNDEBUG 371 #ifndefNDEBUG
371CString tmp; 372CString tmp;
372 tmp.Format("%u - %s - %u\n",tftpRQ->Opcode(),inet_ntoa(sin.sin_addr),sin.sin_port); 373 tmp.Format("%u - %s - %u\n",tftpRQ->Opcode(),inet_ntoa(sin.sin_addr),sin.sin_port);
373 TRACE0(tmp); 374 TRACE0(tmp);
374#endif 375#endif
375POSITION p = m_Daddy->m_Xfers.GetStartPosition(); 376POSITION p = m_Daddy->m_Xfers.GetStartPosition();
376 while(p){ 377 while(p){
377 SOCKET key; 378 SOCKET key;