⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.cpp

📁 大家共同进步! 大家共同进步! 大家共同进步!
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "Img_ListView1.h"


#include "talkroomframe.h"
#include "y_c.h"

#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

int ReadUserMessage(CGfxOutBarCtrl *wndBar,WORD Y_UserQicqNo);//以一个全局变量为基础开始读
int WriteAFileForTest(char *FileName);

extern int SendInit();
extern int SendData(WORD Command,WORD RecvUserID,char *SendBuffer);
extern WORD CurrentUserID;
extern struct SOCKUSERDEF SockUserDef;
CTalkRoomFrame *talkFrame;

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_WM_CLOSE()
	ON_WM_SHOWWINDOW()
	ON_WM_GETMINMAXINFO()
	ON_WM_SETTINGCHANGE()
	ON_WM_SIZE()
	ON_COMMAND(ID_FIND, OnFind)
	ON_COMMAND(ID_CALL, OnCall)
	ON_COMMAND(ID_QICQ, OnQicq)
	ON_COMMAND(ID_SET, OnSet)
	ON_COMMAND(ID_TALKROOM, OnTalkroom)
	ON_WM_INITMENU()
	ON_COMMAND(ID_SHOWTOOL, OnShowtool)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
	ON_MESSAGE(WM_MY_MESSAGE,OnLiben)
	ON_MESSAGE(WM_ANIMDISP,OnAnimTrim)
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
    for(int i=0;i<5;i++)
    {
        m_atbb[i].iBitmap =NULL;
        m_atbb[i].fsState =TBSTATE_ENABLED;
        m_atbb[i].fsStyle =TBSTYLE_BUTTON;
        m_atbb[i].dwData =0;
        m_atbb[i].iString =i;
    }
    m_atbb[0].idCommand =ID_TALKROOM;
    m_atbb[1].idCommand =ID_FIND;
    m_atbb[2].idCommand =ID_CALL;
    m_atbb[3].idCommand =ID_SET;
    m_atbb[4].idCommand =ID_QICQ;
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
NOTIFYICONDATA tnd;

tnd.cbSize=sizeof(NOTIFYICONDATA);

tnd.hWnd=this->m_hWnd;

tnd.uID=IDR_TASK;

tnd.uFlags=NIF_MESSAGE|NIF_ICON|NIF_TIP;

tnd.uCallbackMessage=WM_MY_MESSAGE;

tnd.hIcon=LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_TASK));

strcpy(tnd.szTip,"QICQ");
//if(!Debug_FirstIn)
{
Shell_NotifyIcon(NIM_ADD,&tnd);
//Debug_FirstIn=1;
}


	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM|CBRS_NOALIGN
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	if (!m_wndToolBar2.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM|CBRS_NOALIGN
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar2.LoadToolBar(IDR_MAINFRAME1))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}
//AFX_IDS_IDLEMESSAGE
//    m_wndStatusBar.SetWindowText ("adsadfds");

    if(!m_ToolTip.Create(this,TTS_ALWAYSTIP|WS_CHILD|WS_VISIBLE))
    {
		TRACE0("Failed to create ToolTip control\n");
		return -1;      // fail to create
    }
    m_ToolTip.AddTool(&m_wndStatusBar,"状态条");
	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);//让第一个工具条可移动
//	m_wndToolBar2.EnableDocking(CBRS_ALIGN_ANY);//第二个工具条不可移动
	this->SetWindowText ("dsfsdf");
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);
	SetTimer(4,100,NULL);//此定时器,用来定时检测上线或下线的好友,似无必要
	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs
//lpCreateStruct->style =SW_SHOW|WS_BORDER;
//cs.style =WS_EX_DLGMODALFRAME|WS_MINIMIZEBOX|WS_CAPTION|WS_SYSMENU|WS_EX_TOPMOST;
    char *tempString;
    char tempString1[100];
    sprintf(tempString1,"%d",CurrentUserID);
    tempString=tempString1;
cs.lpszName = tempString;
//cs.style =WS_EX_TOPMOST;
int cx=::GetSystemMetrics (SM_CXSCREEN);
int cy=::GetSystemMetrics (SM_CYSCREEN);
cs.cx =cx/12;
cs.cy = (int)(cy*1.4)/2;
cs.x =cx-cs.cx -50;
cs.y =60;
//AfxGetApp()->m_pMainWnd->SetWindowPos (NULL ,cs.x,cs.y,cs.cx,cs.cy ,WS_EX_TOPMOST);
	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers


BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
	// TODO: Add your specialized code here and/or call the base class
	if (!wndSplitter.CreateStatic(this, 1, 2)) return false;

	if (!wndSplitter.CreateView(0, 1, pContext->m_pNewViewClass, CSize(0,0), pContext)) return false;

	DWORD dwf = CGfxOutBarCtrl::fDragItems|CGfxOutBarCtrl::fEditGroups|CGfxOutBarCtrl::fEditItems|CGfxOutBarCtrl::fRemoveGroups|
				CGfxOutBarCtrl::fRemoveItems|CGfxOutBarCtrl::fAddGroups|CGfxOutBarCtrl::fAnimation;
//				|CGfxOutBarCtrl::fSelHighlight;


	wndBar.Create(WS_CHILD|WS_VISIBLE, CRect(0,0,0,0), &wndSplitter, wndSplitter.IdFromRowCol(0, 0), dwf);
	wndBar.SetOwner(this);

//	imaLarge.Create(IDB_IMAGELIST, 32, 0, RGB(128,128,128));
//	imaSmall.Create(IDB_SMALL_IMAGELIST, 16, 0, RGB(0,128,128));

	imaLarge.Create(IDB_IMAGELIST, 32, 0, RGB(128,128,128));
	imaSmall.Create(IDB_SMALL_IMAGELIST, 16, 0, RGB(128,128,128));

	wndBar.SetImageList(&imaLarge, CGfxOutBarCtrl::fLargeIcon);
	wndBar.SetImageList(&imaSmall, CGfxOutBarCtrl::fSmallIcon);

	wndBar.SetAnimationTickCount(20);

	wndBar.SetAnimSelHighlight(200);


	CRect r;
	GetClientRect(&r);

	int w1 = r.Width();
	int w2 = r.Width();

	wndSplitter.SetColumnInfo( 0, w1, 0 );
	wndSplitter.SetColumnInfo( 1, w2, 0 );

	wndSplitter.RecalcLayout();

    ReadUserMessage((CGfxOutBarCtrl *)&wndBar,10001);
//	int w1 = r.Width()/5;
//	int w2 = r.Width()/4;
	return true;
	
//	return CFrameWnd::OnCreateClient(lpcs, pContext);
}

void CMainFrame::OnClose() 
{
	// TODO: Add your message handler code here and/or call default

NOTIFYICONDATA tnid;

tnid.cbSize=sizeof(NOTIFYICONDATA);

tnid.hWnd=this->m_hWnd;

tnid.uID=IDR_TASK;//保证删除的是我们的图标

Shell_NotifyIcon(NIM_DELETE,&tnid);

AfxPostQuitMessage(0);

	
	CFrameWnd::OnClose();
}

void CMainFrame::OnLiben(WPARAM wParam, LPARAM lParam)
{

UINT uID;//发出该消息的图标的ID
UINT uMouseMsg;//鼠标动作

POINT pt;

uID=(UINT) wParam;

uMouseMsg=(UINT) lParam;

	if(uMouseMsg==WM_LBUTTONDOWN)
	{
		switch(uID)
		{

			case IDR_TASK://如果是我们的图标
				GetCursorPos(&pt);//取得鼠标位置
		AfxGetApp()->m_pMainWnd->ShowWindow (SW_SHOWNORMAL|SW_HIDE);
		AfxGetApp()->m_pMainWnd->UpdateWindow ();
				break;
			default:
				break;
		}
	}
	return;
}

void CMainFrame::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CFrameWnd::OnShowWindow(bShow, nStatus);

	// TODO: Add your message handler code here
	
}

BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}

BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CFrameWnd::OnCommand(wParam, lParam);
}

void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
{
	// TODO: Add your message handler code here and/or call default

	CFrameWnd::OnGetMinMaxInfo(lpMMI);
}

void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) 
{
	CFrameWnd::OnSettingChange(uFlags, lpszSection);
	
	// TODO: Add your message handler code here
	
}

void CMainFrame::OnSize(UINT nType, int cx, int cy) 
{
	CFrameWnd::OnSize(nType, cx, cy);
	switch(nType)
	{
	case SIZE_MAXIMIZED   :
		break;
	case SIZE_MINIMIZED:
		AfxGetApp()->m_pMainWnd->ShowWindow (SIZE_RESTORED);
		AfxGetApp()->m_pMainWnd->UpdateWindow ();
		break;
	case SIZE_RESTORED:
		break;
	}
	// TODO: Add your message handler code here
	
}

void CMainFrame::OnFind() 
{
	// TODO: Add your command handler code here
	
}

void CMainFrame::OnCall() 
{
	// TODO: Add your command handler code here
	
}

void CMainFrame::OnQicq() 
{
	// TODO: Add your command handler code here
	
}

void CMainFrame::OnSet() 
{
	// TODO: Add your command handler code here
	
}

void CMainFrame::OnTalkroom() 
{
	// TODO: Add your command handler code here
	    talkFrame = new CTalkRoomFrame;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -