Skip to content

Instantly share code, notes, and snippets.

@nibasya
nibasya / DragDropListBox.cpp
Created Feb 8, 2016
Example of CListBox function which holds scroll bar position during insertion/ removal of item
View DragDropListBox.cpp
void CDragDropListBox::SwapItem(int newIndex)
{
DWORD data;
CString str;
int top;
SetRedraw(FALSE);
top = GetTopIndex();
GetText(newIndex, str);
View KanmusuListMakerDlg.cpp
// Delete section
- WriteProfileString(IntToStr(i), NULL, 0);
+ ret = AfxGetApp()->WriteProfileString(IntToStr(i), NULL, NULL);
+ if (ret == 0) {
+ MessageBox(GetLastErrorString());
+ }
View ImageMatching.cpp
matchTemplate(src, ptn, dst, CV_TM_CCOEFF_NORMED);
minMaxLoc(dst, NULL, &max_val, NULL, &max_loc);
if(max_val>0.98){ // srcとptnがほぼ一致してたら、何かする
}
View CImageToCvMat
CRect targetRect;
CImage img;
cv::Mat tmp;
pWnd->GetClientRect(&targetRect);
img.Create(targetRect.Width(), targetRect.Height(), 24);
/* snip some codes */
// 画像イメージ変換
View CImageToCvMat
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();
View stdafx.h
#ifndef WINVER // Windows Vista 以降のバージョンに固有の機能の使用を許可します。
#define WINVER 0x0600 // これを Windows の他のバージョン向けに適切な値に変更してください。
#endif
#ifndef _WIN32_WINNT // Windows Vista 以降のバージョンに固有の機能の使用を許可します。
#define _WIN32_WINNT 0x0600 // これを Windows の他のバージョン向けに適切な値に変更してください。
#endif
View ChangeFileNameGUIDlg.cpp
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;
@nibasya
nibasya / 2_Increment_in_a_line_ex2.c
Created May 12, 2018
Example of code including 2 increments in a line
View 2_Increment_in_a_line_ex2.c
#include <stdio.h>
int Sum(const int in) {
printf("input=%d\n", in);
return in;
}
int main()
{
int p = 0;
@nibasya
nibasya / 2_Increment_in_a_line_ex1.c
Created May 12, 2018
An example of code including 2 increments in a line
View 2_Increment_in_a_line_ex1.c
#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_ex3.c
Created May 12, 2018
An example of code including 2 increments in a line
View 2_Increment_in_a_line_ex3.c
#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;
You can’t perform that action at this time.