ハルhal
デジタル コンテンツ

pc2

作って学ぶ
ハードとソフト

アルゴリズム
電子回路

 






このサイトはHPです
ブログではありません
要望・意見は
下記の掲示場を利用して
下さいまたブログも見て下さい

 

ロボット・DOSV掲示板兼Blog

懐かしのコンピュータ
Apple II Apple2
PC9801 PC9821

roboto

Topに戻る

ララ Lara
アナログ コンテンツ

Lara座れ
動画で学ぶ
躾と訓練
動画メニュー


工作


集団練習メニュー


しつけ 訓練コラム




最後にララについて

このサイトはHPです
ブログではありません
要望・意見は
下記の掲示場を利用して
下さいまたブログも見て下さい

Laraララの
ブログ

犬のしつけと訓練
掲示板


掲示板の利用規則

 

 

 

 

Lara伏せ
Topに戻る
松本 ワンワンクラブ
わんわんクラブ

 

回答済みVisual Studio C++ 2008/2010 Express EditionでWindowsフォームアプリケーションでwin32apiを使用する。

回答済みVisual Studio C++ 2008/2010 Express EditionでWindowsフォームアプリケーションではC++/CLIが採用されているので、.NET Frameworkを使用する。
有料版にはMFCが付いているが、無料版にはない。Formアプリケーションにwin32apiを使用することは御法度のようであるが、邪道で使う方法

までプロジェクトでFormアプリケーションを作成

stdafx.hに次を追加

#include "stdafx.h"
#include <windows.h>
#include <Winuser.h>

追加オプションに

/INCREMENTAL /NOLOGO "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib"

を入れてしまいましょう。


Formでwin32apiを使用 例 ディスプレイの解像度を表示

例 ダウンロード exe zip

赤字が入力したもの

stdafx.cppの中身

#include "stdafx.h"
#include <windows.h>
#include <Winuser.h>

stdafx.hの中身

#pragma once
#include"windows.h"
#include "commctrl.h"
#include <SDKDDKVer.h>

Form1.hの中身

#pragma once
using namespace System::Diagnostics;

namespace disp32form1 {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

/// <summary>
/// Form1 の概要
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: ここにコンストラクター コードを追加します

//EnableWindow(ListView_GetHeader(reinterpret_cast

(this->listView1->Handle.ToInt32())),FALSE);
//
}

protected:
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::ListBox^ listBox1;
private: System::Windows::Forms::RichTextBox^ richTextBox1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::TextBox^ textBox2;

private:
/// <summary>
/// 必要なデザイナー変数です。
/// </summary>
System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
/// <summary>
/// デザイナー サポートに必要なメソッドです。このメソッドの内容を
/// コード エディターで変更しないでください。
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->listBox1 = (gcnew System::Windows::Forms::ListBox());
this->richTextBox1 = (gcnew System::Windows::Forms::RichTextBox());
this->button2 = (gcnew System::Windows::Forms::Button());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(709, 19);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(78, 19);
this->button1->TabIndex = 0;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(488, 19);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(179, 19);
this->textBox1->TabIndex = 1;
//
// listBox1
//
this->listBox1->FormattingEnabled = true;
this->listBox1->ItemHeight = 12;
this->listBox1->Location = System::Drawing::Point(80, 101);
this->listBox1->Name = L"listBox1";
this->listBox1->Size = System::Drawing::Size(271, 280);
this->listBox1->TabIndex = 2;
//
// richTextBox1
//
this->richTextBox1->Location = System::Drawing::Point(488, 104);
this->richTextBox1->Name = L"richTextBox1";
this->richTextBox1->Size = System::Drawing::Size(281, 267);
this->richTextBox1->TabIndex = 3;
this->richTextBox1->Text = L"";
//
// button2
//
this->button2->Location = System::Drawing::Point(341, 19);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 19);
this->button2->TabIndex = 4;
this->button2->Text = L"button2";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(105, 20);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(193, 19);
this->textBox2->TabIndex = 5;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(881, 450);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->button2);
this->Controls->Add(this->richTextBox1);
this->Controls->Add(this->listBox1);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->button1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();

}

#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
System::Drawing::Size^ size;
size = SystemInformation::PrimaryMonitorSize;
textBox1->Text=size->Width.ToString() + " X " + size->Height.ToString();
MessageBox::Show(size->Width.ToString() + " X " + size->Height.ToString());

//使用できるディスプレイモードの確認
String^ text;
static DEVMODE dispmode; // ディスプレイモード
static int disp_no;

// 使用できるディスプレイモードをリッチテキスト 表示
disp_no = 0;
text="";
richTextBox1->Clear();
while( TRUE )
{
//全モードの列挙
if( !EnumDisplaySettings( NULL, disp_no, &dispmode ) ){ break; }
// リッチテキストに表示する
text=disp_no.ToString()+" "+dispmode.dmPelsWidth.ToString()+" "+dispmode.dmPelsHeight.ToString()+" "+dispmode.dmBitsPerPel.ToString()+"\n";
richTextBox1->SelectedText = text;
disp_no++;
}
/*-------------------
richTextBox1->SaveFile("C:\\dispmode.rtf");
richTextBox1->LoadFile("C:\\dispmode.rtf");
-------------------*/
// 使用できるディスプレイモードをリストボックスに表示
disp_no = 0;
text="";
while( TRUE )
{
//全モードの列挙
if( !EnumDisplaySettings( NULL, disp_no, &dispmode ) ){ break; }
// リッチテキストに表示する
text=disp_no.ToString()+" "+dispmode.dmPelsWidth.ToString()+" "+dispmode.dmPelsHeight.ToString()+" "+dispmode.dmBitsPerPel.ToString()+"\n";
listBox1->Items->Add(text);
disp_no++;
}



}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {

}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
Debug::WriteLine(listBox1->Text);
textBox2->Text=listBox1->Text;


}
};
}


つづく

 
動画が旨くご覧いただけない場合は最新のFlash Playerをインストールしてください
web ブラウザがインターネットエクスプローラ6(IE6)以下の場合メニューが崩れてしまうことがあります。
インターネットエクスプローラ7、Sleipnir、Mozilla Firefoxをご使用ください。