vc++ 6.0 专用
1、如何增加、删除External Dependencies中的文件,External Dependencies的意思是,没有把这里的文件加入到这个工程中,但是需要这里的文件的支持,工程中包含的头文件、库文件,若不包含在当前工程project下,就会放在external Dependencies下,External Dependencies是工程要用到的文件,可以不必理它
2、头文件,库链接错误,解决办法,tools -> options -> directories, vc6\vc98\ ,头文件包含,INCLUDE , MFC\INCLUDE , ATL\INCLUDE;库,LIB,MFC\LIB,例如,#include "afxres.h", 编译出错,问题是头文件路径没有设置,Tool -> Options -> Directories ,设置该头文件的包含路径,X:\VC6\VC98\MFC\Include
3、编译链接错误原因( error LNK2001: unresolved external symbol __)库函数没有,代码函数也没有,确引用了该函数(特别是多文件编译会发生)
4、链接错误,如果你编写传统的C程序,必须建立Win32 Console程序,但VC里面默认的是Win32 Application,于是链接错误出现了。[Project] --> [Settings] --> 选择"Link"属性页,在Project Options中将/subsystem:windows改成/subsystem:console
5、找不到msvcrtd.dll mfc42d.dll mfco42d.dll解决办法,build->Set Active Configuration,xxx - Win32 Release OK
6、vc++ 6.0中注释的快捷键,默认是没有的,设定方法
方法1,Tools->Macro,在出现的对话框中点击:Options,选择Load files,在出现的窗口中勾选Sample,关闭,再次打开Tools->Macro在出现的对话框,Macro File选中SAMPLE,以及列表框中的CommentOut,点击Options,点击KetStrokes,选中CommentOut,然后换到 Press new shortcut ,自己设定即可按下你想设定的键,点击Assign保存就OK了。
方法2,Tools -> Customize ->Add-ins and Macro Files,把SAMPLE前面打上钩,Commands,Category选Macros,然后在Commands中把CommentOut拖曳到工具栏(会跳出来图标选择对话框,随便设定一下就行了)。
方法3,安装Visual Assist X,tools->customize->keyboard->category(Add-ins),选择VAssistXSelectionBlockComment,设置快捷键
7、中文输入没有可选项,安装第三方中文输入法,比如搜狗输入法
8、OpenGL,绘制图形,去除控制台窗口, #pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"") 或者 vc6.0 ,Project->setting->Link->Project Options 在右下角的Project Options里面找到/subsytem:,并把其后面其后面的参数改成为windows,然后再找到/entry:,把其后面的值改成”mainCRTStartup”,如果找不到就添加
9、vc简易窗口代码实现
#include<windows.h>
//#include<stdio.h>
#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
LRESULT CALLBACK WinDouProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
class CWnd
{
public:
CWnd()
{
m_hWnd = NULL;
}
BOOL CreateEx(
DWORD dwExStyle, // extended window style
LPCTSTR lpClassName, // pointer to registered class name
LPCTSTR lpWindowName, // pointer to window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // handle to menu or child-window identifier
HANDLE hInstance, // handle to application instance
LPVOID lpParam // pointer to window-creation data
);
BOOL ShowWindow( int nCmdShow );
BOOL UpdateWindow();
public:
HWND m_hWnd;
};
BOOL CWnd::CreateEx(
DWORD dwExStyle, // extended window style
LPCTSTR lpClassName, // pointer to registered class name
LPCTSTR lpWindowName, // pointer to window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // handle to menu or child-window identifier
HANDLE hInstance, // handle to application instance
LPVOID lpParam // pointer to window-creation data
)
{
m_hWnd = ::CreateWindowEx (dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nWidth,nHeight,hWndParent,hMenu,(HINSTANCE)hInstance,lpParam);
if(m_hWnd != NULL)
return TRUE;
else
return FALSE;
}
BOOL CWnd::ShowWindow(int nCmdShow)
{
return ::ShowWindow(m_hWnd,nCmdShow);
}
BOOL CWnd::UpdateWindow()
{
return ::UpdateWindow(m_hWnd);
}
//int WINAPI WinMain(
int main(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
)
{
WNDCLASS wndclass; //先设计窗口类
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH);
wndclass.hCursor = LoadCursor(NULL,IDC_HELP);
wndclass.hIcon = LoadIcon(NULL,IDI_WARNING);
wndclass.hInstance = hInstance;
wndclass.lpfnWndProc = WinDouProc;
wndclass.lpszClassName = "Magic_Maggie";
wndclass.lpszMenuName = 0;
wndclass.style = CS_VREDRAW | CS_HREDRAW;
//某一个变量 几个变量去掉一个特征,可以用取反(~)后再进行与(&)
//例如:style上去掉CS_NOCLOSE,可以style&~CS_NOCLOSE;
RegisterClass(&wndclass); ///注意先建立再注册昂
CWnd wnd;
wnd.CreateEx(NULL,"Magic_Maggie","DouDou",WS_OVERLAPPEDWINDOW,0,0,800,600,NULL,NULL,hInstance,NULL);
wnd.ShowWindow(SW_SHOWNORMAL);
wnd.UpdateWindow();
MSG msg; //消息循环
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg); //触发WinDouProc
}
return 0;
}
LRESULT CALLBACK WinDouProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg)
{
case WM_LBUTTONDOWN:
MessageBox(hwnd,"您按下了鼠标左键","mmmmmmmmmm",MB_OK);
HDC hdc;
hdc = GetDC(hwnd);
//The GetDC function retrieves a handle to a display device context for the client area of a specified window or for the entire screen. You can use the returned handle in subsequent GDI functions to draw in the device context.
TextOut(hdc,0,0,"ttttttttt",strlen("ttttttttt"));
ReleaseDC(hwnd,hdc);
break;
case WM_CHAR:
char szChar[20];
// sprintf(szChar,"Char is %d",wParam);
MessageBox(hwnd,szChar,"程序",MB_OK);
break;
case WM_PAINT:
PAINTSTRUCT ps;
HDC hDc;
hDc = BeginPaint(hwnd,&ps);
TextOut(hDc,0,0,"重绘",strlen("重绘"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE: //这个case与下边的destroy这个case不要弄错了,否则窗口不出现,但任务管理器中运行
if(IDYES == MessageBox(hwnd,"您真的要退出么?","mmmmmmmm",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
//////////////////////////////////////////?????????????????????
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam); // 别忘记了return
}
return 0;
}
10、把Microsoft Visual Studio 10.0\VC\bin 下的cvtres.exe 重命名,解决vc2010链接错误(电脑中的版本高)
11、VS2013调试窗口一闪而过的解决方法,右键单击当前工程,进入属性界面,链接器-系统-子系统,子系统配置"控制台(/SUBSYSTEM:CONSOLE)",然后执行运行即Ctrl+F5
12、用VS2013生成的.obj文件、.lib库、.dll库、.exe执行文件,如果想查看其中这些文件或库包含了哪些函数以及相关的信息(符号清单),可以通过VS2013自带的dumpbin工具来完成,dumpbin.exe D:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin
13、VS加载符号慢的解决办法:打开VS的【工具】-【选项】-【调试】-【符号】1、先取消勾选“Microsoft符号服务器”;2、清空符号缓存;3、重启VS
14、VS scanf等 安全报错解决办法:第一,加 _s;第二,在文件前面(头文件前面)加宏 #define _CRT_SECURE_NO_DEPRECATE;第三,设置,项目 --> 属性 --> C/C++ --> 高级 --> 禁用特定警告,填写编译错误代码,比如 4996
15、VC++ 6.0,工程图形界面: 左边工程的 resourse 点开,点 dialog,图形设计界面就显示出来了
16、VC++ 6.0,代码格式化快捷键: Alt + F8
17、VS2013,_pFirstBlock==pHead 错误的解决方法,确认VS工程属性中,opencv的链接库路径和版本正确;VS2013应该使用vc12目录,VS2012对应vc11目录;debug版和release版要区分;VS工程的运行库参数应该使用"/MDd";系统环境变量Path中,opencv的目录和VS工程设置的路径 应该一致。
18、VS2013,错误列表不显示解决办法,勾选当前项目