Skip to content

Instantly share code, notes, and snippets.

@nibasya
nibasya / DragDropListBox.cpp
Created February 8, 2016 16:39
Example of CListBox function which holds scroll bar position during insertion/ removal of item
void CDragDropListBox::SwapItem(int newIndex)
{
DWORD data;
CString str;
int top;
SetRedraw(FALSE);
top = GetTopIndex();
GetText(newIndex, str);
@nibasya
nibasya / KanmusuListMakerDlg.cpp
Created March 21, 2016 05:23
.ini entry not deleted
// Delete section
- WriteProfileString(IntToStr(i), NULL, 0);
+ ret = AfxGetApp()->WriteProfileString(IntToStr(i), NULL, NULL);
+ if (ret == 0) {
+ MessageBox(GetLastErrorString());
+ }
matchTemplate(src, ptn, dst, CV_TM_CCOEFF_NORMED);
minMaxLoc(dst, NULL, &max_val, NULL, &max_loc);
if(max_val>0.98){ // srcとptnがほぼ一致してたら、何かする
}
CRect targetRect;
CImage img;
cv::Mat tmp;
pWnd->GetClientRect(&targetRect);
img.Create(targetRect.Width(), targetRect.Height(), 24);
/* snip some codes */
// 画像イメージ変換
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();
#ifndef WINVER // Windows Vista 以降のバージョンに固有の機能の使用を許可します。
#define WINVER 0x0600 // これを Windows の他のバージョン向けに適切な値に変更してください。
#endif
#ifndef _WIN32_WINNT // Windows Vista 以降のバージョンに固有の機能の使用を許可します。
#define _WIN32_WINNT 0x0600 // これを Windows の他のバージョン向けに適切な値に変更してください。
#endif
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 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;
@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_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;