Skip to content

Instantly share code, notes, and snippets.

@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 / 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."
LRESULT CKCSSDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_SETCURSOR) {
if (HIWORD(lParam) == WM_RBUTTONUP) {
CPoint p;
GetCursorPos(&p);
ScreenToClient(&p);
ShowPopupMenu(p);
}
}
@nibasya
nibasya / KCSSDlg.cpp
Last active August 29, 2018 15:04
Updating CProgressCtrl State
// Updates progress bar
void CKCSSDlg::UpdateInfo()
{
double mem = m_MemUse;
mem = mem / m_MemMax;
if (mem > 0.8){
m_CtrlProgressMemory.SetState(PBST_PAUSED);
}
else if (mem > 0.95) {
@nibasya
nibasya / KCSSDlg.cpp
Created August 29, 2018 16:10
Disabling Progress Bar Animation and let SetState Affect Immediately
// Updates progress bar and text
void CKCSSDlg::UpdateInfo()
{
double mem = m_MemUse;
mem = mem / m_MemMax;
if (mem > 0.9){
m_CtrlProgressMemory.SetState(PBST_ERROR);
}
else if (mem >= 0.8) {
void CSettingSave::OnCancel()
{
// Empty function to avoid closure by ESC key
}
@nibasya
nibasya / InfoProgressCtrl.cpp
Created September 1, 2018 06:31
Add text on progress control
/****************************************************************************
Name: InfoProgresssCtrl.h
Desc: CProgressCtrlに文字情報表示機能を追加.
Author: donadona
reidphoaさんのInfoProgressBar.hより改変
*********************************************************************/
// InfoProgressCtrl.cpp : インプリメンテーション ファイル
//
/*
03/08/03 CRgn を用いてクリッピングするようにした
3D表示に対応した
18/08/29 クラス名をCInfoProgressBarからCInfoProgressCtrlに変更。
CProgressCtrlのバー表示機能を残したまま、上にテキストを表示するよう変更。
独自のバー表示機能は削除。SetColorをSetTxtColorに変更。
@nibasya
nibasya / DE10Controller.cs
Last active August 13, 2019 03:30
A class representing an group of data
[System.Serializable]
public class Wheel
{
public List<Rigidbody> wheels;
public float wheelMass = 600; // mass of each wheel pair without flange mass; i.e. twice the mass of 1 wheel without flange mass
}
@nibasya
nibasya / DE10Controller.cs
Last active August 13, 2019 03:30
An example using the grouped data
public float targetVelocity; // target speed of rotation
public float torque; // a torque to be applied to each wheel
public Wheel wheel; // a group of setting related to wheels
// Start is called before the first frame update
void Start()
{
foreach(Rigidbody rb in wheel.wheels)
{
rb.mass = wheel.wheelMass;