Skip to content

Instantly share code, notes, and snippets.

@nibasya
nibasya / Example.cpp
Last active February 22, 2020 10:25
Get CString object from GetLastError information
#include "stdafx.h"
#include "CGetLastError.h"
void main()
{
// snip
SetLastError(111); // create a error 111 (ERROR_BUFFER_OVERFLOW) for demo
// Message Box with a text associated to 111(ERROR_BUFFER_OVERFLOW) appears.
// In English: "The file name is too long."
@nibasya
nibasya / ConvertString
Created June 23, 2018 06:37
Example of converting from Unicode to ANSI
extern void MyOpen(LPCSTR name);
void MyFunc(CStringW name){
MyOpen(CW2A(name));
}
@nibasya
nibasya / 2_Increment_in_a_line_ex3.c
Created May 12, 2018 07:57
An example of code including 2 increments in a line
#include <stdio.h>
int Sum1(const int in) {
printf("Sum1 input=%d\n", in);
return in;
}
int Sum2(const int in) {
printf("Sum2 input=%d\n", in);
return in;
@nibasya
nibasya / 2_Increment_in_a_line_ex1.c
Created May 12, 2018 04:55
An example of code including 2 increments in a line
#include <stdio.h>
int main()
{
int p = 0;
int sum;
char buff[128];
sum = (p++) + (p++);
printf("sum=%d p=%d\n", sum, p);
@nibasya
nibasya / 2_Increment_in_a_line_ex2.c
Created May 12, 2018 04:54
Example of code including 2 increments in a line
#include <stdio.h>
int Sum(const int in) {
printf("input=%d\n", in);
return in;
}
int main()
{
int p = 0;
void CChangeFileNameGUIDlg::GetDirName(CEdit* pEdit)
{
IFileDialog *pDialog=NULL;
HRESULT hr;
DWORD options;
// インスタンス生成
hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pDialog));
if (FAILED(hr))
return;
#ifndef WINVER // Windows Vista 以降のバージョンに固有の機能の使用を許可します。
#define WINVER 0x0600 // これを Windows の他のバージョン向けに適切な値に変更してください。
#endif
#ifndef _WIN32_WINNT // Windows Vista 以降のバージョンに固有の機能の使用を許可します。
#define _WIN32_WINNT 0x0600 // これを Windows の他のバージョン向けに適切な値に変更してください。
#endif
CImage img;
cv::Mat tmp;
int i;
size_t matPitch;
uchar *pTmpData;
BYTE *pImgData;
matPitch = tmp.cols*tmp.elemSize();
pTmpData = tmp.data + (img.GetHeight()-1)*matPitch;
pImgData = (BYTE*)img.GetBits();
CRect targetRect;
CImage img;
cv::Mat tmp;
pWnd->GetClientRect(&targetRect);
img.Create(targetRect.Width(), targetRect.Height(), 24);
/* snip some codes */
// 画像イメージ変換
matchTemplate(src, ptn, dst, CV_TM_CCOEFF_NORMED);
minMaxLoc(dst, NULL, &max_val, NULL, &max_loc);
if(max_val>0.98){ // srcとptnがほぼ一致してたら、何かする
}