C# と VB.NET の質問掲示板

ASP.NET、C++/CLI、Java 何でもどうぞ

ログ内検索
  • キーワードを複数指定する場合は 半角スペース で区切ってください。
  • 検索条件は、(AND)=[A かつ B] (OR)=[A または B] となっています。
  • [返信]をクリックすると返信ページへ移動します。
キーワード/ 検索条件 /
検索範囲/ 強調表示/ ON (自動リンクOFF)
結果表示件数/ 記事No検索/ ON
大文字と小文字を区別する

全過去ログを検索

<< 0 >>
■606  Re[3]: タスクバーの非表示について
□投稿者/ なみ -(2005/06/14(Tue) 20:55:56)

    分類:[VB.NET] 

    質問の仕方が悪く、すみませんでした。

    本来タスクバーがあるところまでフォームを最大表示したいのです。

    > Call ShowWindow(FindWindow("Shell_TrayWnd", vbNullString), SW_HIDE)
    > Call ShowWindow(FindWindow("Shell_TrayWnd", vbNullString), SW_SHOW)

    試してみたのですが、タスクバーのあるところにWindowsのデスクトップが
    出てきてしまっていて、フォームが途中で切れてしまうのです。

    それで、GetWindowPlacement・SetWindowPlacement関数を使用して
    タスクバーの高さを0にするようにしたのですが、VB6では正常に実行されるのですが
    VB.NETではどちらの関数も戻り値「-4294967296」が返ってきて何も起こりませんでした。

    AppBar_HWnd = FindWindow("Shell_TrayWnd", vbNullString)
    Default_WindowPlacement.Length = Len(Default_WindowPlacement)
    Default_WindowPlacement.flags = 0
    Default_WindowPlacement.ptMinPosition.X = 0
    Default_WindowPlacement.ptMaxPosition.Y = 0
    Default_WindowPlacement.ptMaxPosition.X = 0
    Default_WindowPlacement.ptMaxPosition.Y = 0
    Default_WindowPlacement.rcNormalPosition.Bottom = 0
    Default_WindowPlacement.rcNormalPosition.left = 0
    Default_WindowPlacement.rcNormalPosition.Right = 0
    Default_WindowPlacement.rcNormalPosition.Top = 0
    Default_WindowPlacement.showCmd = 0
    ret = GetWindowPlacement(AppBar_HWnd, Default_WindowPlacement)
    New_WindowPlacement = Default_WindowPlacement
    ret = SetWindowPlacement(AppBar_HWnd, New_WindowPlacement)

    宣言の部分で違う点は構造体のTypeをStructureに変換したところだけです。
    この部分が悪いのでしょうか?
    初歩的な質問ですみません。
    よろしくお願いします。
記事No.596 のレス /0過去ログ1より / 関連記事表示
削除チェック/

■7618  Re[7]: フォームの表示方法
□投稿者/ 魔界の仮面弁士 -(2007/09/11(Tue) 16:46:10)
    No7617 (arion さん) に返信
    > 塗りつぶし領域を変化させるのはどのようにすればよろしいのでしょうか?

    Graphics.FromImage(対象Bitmap) で得た Grahpics に対して、
    FillRectangle メソッドを実行してみてください。
記事No.7596 のレス /過去ログ20より / 関連記事表示
削除チェック/

■10218  Re[2]: SQLで表示される項目の表示を変えるには?
□投稿者/ SQL初心者 -(2007/11/14(Wed) 00:20:55)
    みなさん、いろいろとありがとうございます。

    現在の環境としましては、Visual Studio2005、ASP.NET、VB.NETといったところです。

    とりあえずOracleやSQLをいぢってみることにします!
記事No.10208 のレス /過去ログ23より / 関連記事表示
削除チェック/

■11998  Re[7]: VB.NETでBMPからAVIを作成する方法
□投稿者/ moro -(2007/12/26(Wed) 18:05:21)
    > あなたが書いたVBのソースを載せて、どこが悪いのか指摘を受けたほうが有意義だと思いますよ。
    
    よもやまさんに紹介していただいたページをVBに変換しました。
    http://www.adp-gmbh.ch/csharp/avi/write_avi.html
    
    悪い点や誤り等ありましたらご指摘をお願いいたします。
    
    
    以下ソースです。よろしくお願いします。
    ※ToUInt32についてはSystem.Convert.を省略して記載しています。
    
    Imports System
    Imports System.Runtime.InteropServices
    Imports System.Drawing
    Imports System.Drawing.Imaging
    
     _
    
    Public Class AviWriter
    	<StructLayout(LayoutKind.Sequential, Pack:=1)> _
    	Private Structure AVISTREAMINFOW
    		Public fccType, fccHandler, dwFlags, dwCaps As UInt32
    
    		Public wPriority, wLanguage As UInt16
    
    		Public dwScale, dwRate, dwStart, dwLength, dwInitialFrames, dwSuggestedBufferSize, dwQuality, dwSampleSize, rect_left, rect_top, rect_right, rect_bottom, dwEditCount, dwFormatChangeCount As UInt32
    
    		Public szName0, szName1, ..... szName63 As UInt16
    	End Structure 'AVISTREAMINFOW
    	<StructLayout(LayoutKind.Sequential, Pack:=1)> _
    		Private Structure AVICOMPRESSOPTIONS
    		Public fccType As UInt32
    		Public fccHandler As UInt32
    		Public dwKeyFrameEvery As UInt32 ' only used with AVICOMRPESSF_KEYFRAMES
    		Public dwQuality As UInt32
    		Public dwBytesPerSecond As UInt32 ' only used with AVICOMPRESSF_DATARATE
    		Public dwFlags As UInt32
    		Public lpFormat As IntPtr
    		Public cbFormat As UInt32
    		Public lpParms As IntPtr
    		Public cbParms As UInt32
    		Public dwInterleaveEvery As UInt32
    	End Structure 'AVICOMPRESSOPTIONS
    	<StructLayout(LayoutKind.Sequential, Pack:=1)> _
    	 Public Structure BITMAPINFOHEADER
    		Public biSize As UInt32
    		Public biWidth As Int32
    		Public biHeight As Int32
    		Public biPlanes As Int16
    		Public biBitCount As Int16
    		Public biCompression As UInt32
    		Public biSizeImage As UInt32
    		Public biXPelsPerMeter As Int32
    		Public biYPelsPerMeter As Int32
    		Public biClrUsed As UInt32
    		Public biClrImportant As UInt32
    	End Structure 'BITMAPINFOHEADER
    	_
    
    	Public Class AviException
    		Inherits ApplicationException
    
    		Public Sub New(ByVal s As String)
    			MyBase.New(s)
    		End Sub 'New
    
    		Public Sub New(ByVal s As String, ByVal hr As Int32)
    			MyBase.New(s)
    
    			If hr = AVIERR_BADPARAM Then
    				err_msg = "AVIERR_BADPARAM"
    			Else
    				err_msg = "unknown"
    			End If
    		End Sub 'New
    
    
    		Public Function ErrMsg() As String
    			Return err_msg
    		End Function 'ErrMsg
    		Private AVIERR_BADPARAM As Int32 = -2147205018
    		Private err_msg As String
    	End Class 'AviException
    
    	Private Const OF_WRITE As Long = &H1
    	Private Const OF_CREATE As Long = &H1000
    	Private Const OF_SHARE_DENY_NONE As Long = &H40
    	Private Const AVIIF_KEYFRAME As Long = &H10L
    
    	Public Function Open(ByVal fileName As String, ByVal frameRate As UInt32, ByVal width As Integer, ByVal height As Integer) As Bitmap
    		frameRate_ = frameRate
    		width_ = width
    		height_ = height
    		bmp_ = New Bitmap(width, height, PixelFormat.Format24bppRgb)
    		Dim bmpDat As BitmapData = bmp_.LockBits(New Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb)
    		stride_ = bmpDat.Stride
    		bmp_.UnlockBits(bmpDat)
    		AVIFileInit()
    		Dim hr As Integer = AVIFileOpen(pfile_, fileName, OF_CREATE Or OF_WRITE Or OF_SHARE_DENY_NONE, 0)
    
    		If hr <> 0 Then
    			Throw New AviException("error for AVIFileOpen")
    		End If
    
    		CreateStream()
    		SetOptions()
    
    		Return bmp_
    	End Function 'Open
    
    
    	Public Sub AddFrame()
    
    		Dim bmpDat As BitmapData = bmp_.LockBits(New Rectangle(0, 0, CInt(width_), CInt(height_)), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb)
    
    		Dim hr As Integer = AVIStreamWrite(psCompressed_, count_, 1, bmpDat.Scan0, CType(stride_ * height_, Int32), 0, 0, 0)
    		' pointer to data
    		' 16 = AVIIF_KEYFRAMe
    
    		If hr <> 0 Then
    			Throw New AviException("AVIStreamWrite")
    		End If
    
    		bmp_.UnlockBits(bmpDat)
    
    		count_ += 1
    	End Sub 'AddFrame
    
    
    	Public Sub Close()
    		AVIStreamRelease(ps_)
    		AVIStreamRelease(psCompressed_)
    
    		AVIFileRelease(pfile_)
    		AVIFileExit()
    	End Sub 'Close
    
    
    	Private Sub CreateStream()
    		Dim strhdr As New AVISTREAMINFOW
    		strhdr.fccType = fccType_
    		strhdr.fccHandler = fccHandler_
    		strhdr.dwFlags = ToUInt32(0)
    		strhdr.dwCaps = ToUInt32(0)
    		strhdr.wPriority = ToUInt16(0)
    		strhdr.wLanguage = ToUInt16(0)
    		strhdr.dwScale = ToUInt32(1)
    		strhdr.dwRate = frameRate_ ' Frames per Second
    		strhdr.dwStart = ToUInt32(0)
    		strhdr.dwLength = ToUInt32(0)
    		strhdr.dwInitialFrames = ToUInt32(0)
    		strhdr.dwSuggestedBufferSize = ToUInt32(height_ * stride_)
    		strhdr.dwQuality = ToUInt32(4294967295)
    		strhdr.dwSampleSize = ToUInt32(0)
    		strhdr.rect_top = ToUInt32(0)
    		strhdr.rect_left = ToUInt32(0)
    		strhdr.rect_bottom = ToUInt32(height_)
    		strhdr.rect_right = ToUInt32(width_)
    		strhdr.dwEditCount = ToUInt32(0)
    		strhdr.dwFormatChangeCount = ToUInt32(0)
    		strhdr.szName0 = ToUInt16(0)
    		strhdr.szName1 = ToUInt16(0)
    
    		Dim hr As Integer = AVIFileCreateStream(pfile_, ps_, strhdr)
    
    		If hr <> 0 Then
    			Throw New AviException("AVIFileCreateStream")
    		End If
    	End Sub 'CreateStream
    
    
    	Private Sub SetOptions()
    		Dim opts As New AVICOMPRESSOPTIONS
    		opts.fccType = ToUInt32(0) 'fccType_;
    		opts.fccHandler = ToUInt32(0) 'fccHandler_;
    		opts.dwKeyFrameEvery = ToUInt32(0)
    		opts.dwQuality = ToUInt32(0) ' 0 .. 10000
    		opts.dwFlags = ToUInt32(0) ' AVICOMRPESSF_KEYFRAMES = 4
    		opts.dwBytesPerSecond = ToUInt32(0)
    		opts.lpFormat = New IntPtr(0)
    		opts.cbFormat = ToUInt32(0)
    		opts.lpParms = New IntPtr(0)
    		opts.cbParms = ToUInt32(0)
    		opts.dwInterleaveEvery = ToUInt32(0)
    
    		Dim p As AVICOMPRESSOPTIONS
    		Dim pp As AVICOMPRESSOPTIONS
    
    		Dim x As IntPtr = ps_
    		Dim ptr_ps As IntPtr
    
    		AVISaveOptions(0, ToUInt32(0), 1, ptr_ps, pp)
    
    		' TODO: AVISaveOptionsFree(...)
    		Dim hr As Integer = AVIMakeCompressedStream(psCompressed_, ps_, opts, 0)
    		If hr <> 0 Then
    			Throw New AviException("AVIMakeCompressedStream")
    		End If
    
    		Dim bi As New BITMAPINFOHEADER
    		bi.biSize = ToUInt32(40)
    		bi.biWidth = ToDecimal(width_)
    		bi.biHeight = ToDecimal(height_)
    		bi.biPlanes = 1
    		bi.biBitCount = 24
    		bi.biCompression = ToUInt32(0) ' 0 = BI_RGB
    		bi.biSizeImage = ToUInt32(stride_ * height_)
    		bi.biXPelsPerMeter = 0
    		bi.biYPelsPerMeter = 0
    		bi.biClrUsed = ToUInt32(0)
    		bi.biClrImportant = ToUInt32(0)
    
    		hr = AVIStreamSetFormat(psCompressed_, 0, bi, 40)
    		If hr <> 0 Then
    			Throw New AviException("AVIStreamSetFormat", hr)
    		End If
    	End Sub 'SetOptions
    
    	Private Declare Sub AVIFileInit Lib "avifil32.dll" ()
    
    	Private Declare Sub AVIFileExit Lib "avifil32.dll" ()
    
    	Private Declare Function AVIFileOpen Lib "avifil32.dll" _
    			 (ByRef ptr_pfile As Integer, ByVal fileName As String, _
    			  ByVal flags As Integer, ByRef dummy As Integer) As Integer 'byval
    
    	Private Declare Function AVIFileOpenW Lib "avifil32.dll" _
    			 (ByRef ptr_pfile As Integer, ByVal fileName As String, _
    			  ByVal flags As Integer, ByRef dummy As Integer) As Integer 'byval
    
    	Private Declare Function AVIFileCreateStream Lib "avifil32.dll" _
    			  (ByVal ptr_pfile As Integer, ByRef ptr_ptr_avi As IntPtr, _
    			   ByRef ptr_streaminfo As AVISTREAMINFOW) As Long
    
    	Private Declare Function AVIMakeCompressedStream Lib "avifil32.dll" _
    			   (ByRef ppsCompressed As IntPtr, ByVal aviStream As IntPtr, _
    				ByRef ao As AVICOMPRESSOPTIONS, ByVal dummy As Integer) As Integer
    
    	Private Declare Function AVIStreamSetFormat Lib "avifil32.dll" _
    			   (ByVal aviStream As IntPtr, ByVal lPos As Int32, _
    				ByRef lpFormat As BITMAPINFOHEADER, ByVal cbFormat As Int32) As Integer
    
    	Private Declare Function AVISaveOptions Lib "avifil32.dll" _
    		  (ByVal hwnd As Integer, ByVal flags As UInt32, _
    		   ByVal nStreams As Integer, _
    		   ByRef ptr_ptr_avi As IntPtr, ByRef ao As AVICOMPRESSOPTIONS) As Integer 'byval
    
    	Private Declare Function AVIStreamWrite Lib "avifil32.dll" _
    		 (ByVal aviStream As IntPtr, ByVal lStart As Int32, _
    		  ByVal lSamples As Int32, ByVal lpBuffer As IntPtr, _
    		  ByVal cbBuffer As Int32, ByVal dwFlags As Int32, _
    		  ByRef dummy1 As Int32, ByRef dummy2 As Int32) As Integer 'byval
    
    	Private Declare Function AVIStreamRelease Lib "avifil32.dll" _
    			   (ByVal aviStream As IntPtr) As Integer
    
    	Private Declare Function AVIFileRelease Lib "avifil32.dll" _
    			   (ByVal pfile As Integer) As Integer
    
    	Private pfile_ As Integer = 0
    	Private ps_ As New IntPtr(0)
    	Private psCompressed_ As New IntPtr(0)
    	Private frameRate_ As UInt32 = ToUInt32(0)
    	Private count_ As Integer = 0
    	Private width_ As Integer = 0
    	Private stride_ As Integer = 0
    	Private height_ As Integer = 0
    	Private fccType_ As UInt32 = ToUInt32(1935960438) ' vids
    	Private fccHandler_ As UInt32 = ToUInt32(808810089) ' IV50
    	'1145656899;  // CVID
    	Private bmp_ As Bitmap
    End Class 'AviWriter
    
    
記事No.11957 のレス /過去ログ26より / 関連記事表示
削除チェック/

■35040  Re[1]: MS FlexGridにキー入力可のプロパティ
□投稿者/ 魔界の仮面弁士 -(2009/04/17(Fri) 15:27:55)
    No35034 (おへそ七 さん) に返信
    > VS2008に付属のMicrosoft FlexGrid Control version 6.0において
    > セルのキー入力が可能になるプロパティがあるとの(不確かな)
    > 情報を得たのですが、本当にそのようなプロパティがあるのでしょうか?

    ありません。

    MSFlexGrid は、バージョン表記のところに書かれているように、
    もともとは VideoSoft 社製のコントロールです。

    製品版となる VSFlexGrid コントロールには編集機能があるのですが、
    Microsoft に OEM 提供された「機能限定版」である MSFlexGrid は、
    編集機能が意図的に削られています。


    MSFlexGrid で入力が必要な場合には、編集したいセルの上にエディット コントロールを
    重ね置いて対応するか、あるいはキー入力を拾って、それを MSFlexGrid の Text プロパティ等に
    書き写すことで対応してみてください。
記事No.35034 のレス /過去ログ61より / 関連記事表示
削除チェック/

■55697  Re[5]: NumericUpDownコントロールの上下限チェック不具合
□投稿者/ ホエホエ -(2010/12/09(Thu) 16:20:57)
    みなさま、ご返信ありがとうございます。


    shuさん>
    私の方でも
    NumericUpDown1.Maximum = decimal.MaxValue;
    NumericUpDown1.Minimum = decimal.MinValue;

    で試してみましたがダメでした。

    魔界の仮面弁士さんが書かれている通り、NumericUpDownコントロールが
    HexadecimalをtrueにするとInt32の範囲しかダメなようです。

    バグではないにしてもせめてdecimalの範囲内ぐらいはきちんと
    動いて欲しいですねぇ。



    ふーさん>
    上記にもある通り、Maximumにdecimal.MaxValueを設定しても
    ダメでした。

    ちなみに「(decimal)0xFFFFFFFF」であったとしても
    Maximumにはウォッチで見ると「4294967295」が入ってたので
    問題ないようです。



    魔界の仮面弁士さん>
    貴重な情報ありがとうございます。やはりInt32までしかサポートしない
    仕様なんですね。

    サポートするように自信でSystem.Windows.Forms.UpDownBaseクラスの
    派生を作らないとダメなんでしょうかね。
記事No.55671 のレス /過去ログ93より / 関連記事表示
削除チェック/

■56449  Re[4]: ブラウザへのキーイベント発生方法について
□投稿者/ todo -(2011/01/14(Fri) 10:10:59)
記事No.56406 のレス /過去ログ95より / 関連記事表示
削除チェック/

■60309  Re[5]: 同時ダウンロード時の負荷分散について
□投稿者/ うえちゃん -(2011/06/27(Mon) 15:49:47)
    774RRさん、逆運の覇者さん、またまたコメントありがとうございます。

    IISの設定(サイトの詳細設定)にある「最大同時接続数」と「接続のタイムアウト(秒)」を使うことでなんとかなりそうです。
    #デフォルトはそれぞれ「4294967295」と「120(秒)」でした。
    #アプリケーションではなくサイト単位の設定なので、ダウンロード専用のサイトを設ける必要がありますが。。

    試してみたところ、最大同時接続数を超えて接続を試みるとクライアント側に503が返ります。
    また、接続中のクライアントのネットワークケーブルをブチっと引っこ抜き、上記タイムアウト
    時間を経過すると、現在の同時接続数が元に戻ります(切断された)。

    これでなんとか胸が熱くなるな想いをさせずに済むかもしれません。

    お二人ともアドバイスありがとうございました。
記事No.60294 のレス / END /過去ログ101より / 関連記事表示
削除チェック/

■81161  Re[3]: Graphics.DrawLineでのオーバーフローについて
□投稿者/ 魔界の仮面弁士 -(2016/08/31(Wed) 10:43:40)
    No81148 (真田昌幸 さん) に返信
    > >>Integer.MaxValueの箇所を100とかにすると正常に動作することから、Integer.MaxValueで
    > >>オーバーフローが発生しているのは間違いないのですが、DrawLineの引数はInteger型なのに
    > >>何故という疑問があります。
    >>引数がInteger型だからといって、あらゆるメソッドがIntegerの全値域を受け入れなければならないってこともないでしょう。
    >>例えばTCPのポート番号を引数に取るなら、型としてはIntegerを使うでしょうが有効なのは0〜65535だけです。
    > 
    > integerはVB2002以降は32bitかと
    > 16bitなのはVB6までとVBA
    
    VBA は関係無いですよね。
    
    0〜65535 を表せる最小の型は System.UInt16 ですが、
    そのための引数を System.Int32 にするのは珍しいことではありません。
    
    たとえば日付型で、13月や32日を指定できないのは明確ですが、
    DateTime の Month プロパティは、Byte ではなく Integer ですよね。
    
    
    TCP のポート番号は、
     0〜1023 :ウェルノウンポート番号
     〜49151 :登録済みポート番号
     〜65535 :動的・プライベート ポート番号
    であり、この範囲外を認めないというだけの話です。
    
    
    
       【符号なし整数型】
    (a) 0〜255
    (b) 0〜65535
    (c) 0〜4294967295
    (d) 0〜18446744073709551615
    
    
       【符号付き整数型】
    (e)                -128〜127
    (f)              -32768〜32767
    (g)         -2147483648〜2147483647
    (h)-9223372036854775808〜9223372036854775807
    
    ----------------------------
         .NET     VB.NET    VBA         VARIANT
    (a)  Byte     Byte      Byte        VT_UI1 (17)
    (b)  UInt16   UShort    非サポート  VT_UI2 (18)
    (c)  UInt32   UInteger  非サポート  VT_UI4 (19)
    (d)  UInt64   ULong     非サポート  VT_UI8 (21)
    (e)  SByte    SByte     非サポート  VT_I1  (16)
    (f)  Int16    Short     Integer     VT_I2  (2)
    (g)  Int32    Integer   Long        VT_I4  (3)
    (h)  Int64    Long      LongLong    VT_I8  (20)
記事No.81145 のレス /過去ログ138より / 関連記事表示
削除チェック/

■81926  Re[16]: DataSetの破棄について
□投稿者/ 魔界の仮面弁士 -(2016/11/24(Thu) 13:29:07)
    No81924 (sk さん) に返信
    > 素のDataSetに手動でテーブルを追加して

    コードから ds.Tables.Add を呼び出している、ということでしょうか。
    それとも、TableAdapter 無しの型付き DataSet を用意した、という意味でしょうか。


    > @Table = 1 ,Column = 10 の場合
    >  35時間17分20秒 4,294,967,246回で停止。

    &HFFFFFFCE ですね。64bit なら &H00000000FFFFFFCE 。

    UInt32.MaxValue - 4294967246 は 49 なので、
    仮に UInt32 な uncheced カウンターが使われていた場合、
    これに 50 を加えることで、オーバーフローして
    値が 0 に戻ってしまう計算ですが…何だか怪しそうです。



    > ATable = 81 ,Column = 10 の場合
    >  29時間29分8秒 53,024,288回で停止。

    UInt32.MaxValue ÷ 81 = 53,024,287 余り 48

    81 × 53,024,287 = 4,294,967,247 (&H00000000FFFFFFCF) … UInt32 で表現可能
    81 × 53,024,288 = 4,294,967,328 (&H0000000100000020) … UInt32 だと溢れる


    なにか因果関係があるように見えなくもない…。
記事No.81781 のレス /過去ログ140より / 関連記事表示
削除チェック/

■81931  Re[17]: DataSetの破棄について
□投稿者/ sk -(2016/11/24(Thu) 15:04:49)
    No81926 (魔界の仮面弁士 さん) に返信
    > ■No81924 (sk さん) に返信

    > コードから ds.Tables.Add を呼び出している、ということでしょうか。
    > それとも、TableAdapter 無しの型付き DataSet を用意した、という意味でしょうか。

    わかりにくくて申し訳ありません。
    TableAdapter 無しの型付き DataSet を用意したということです。


    >>@Table = 1 ,Column = 10 の場合
    >> 35時間17分20秒 4,294,967,246回で停止。
    >
    > &HFFFFFFCE ですね。64bit なら &H00000000FFFFFFCE 。
    >
    > UInt32.MaxValue - 4294967246 は 49 なので、
    > 仮に UInt32 な uncheced カウンターが使われていた場合、
    > これに 50 を加えることで、オーバーフローして
    > 値が 0 に戻ってしまう計算ですが…何だか怪しそうです。
    >
    >
    >
    >>ATable = 81 ,Column = 10 の場合
    >> 29時間29分8秒 53,024,288回で停止。
    >
    > UInt32.MaxValue ÷ 81 = 53,024,287 余り 48
    >
    > 81 × 53,024,287 = 4,294,967,247 (&H00000000FFFFFFCF) … UInt32 で表現可能
    > 81 × 53,024,288 = 4,294,967,328 (&H0000000100000020) … UInt32 だと溢れる
    >
    >
    > なにか因果関係があるように見えなくもない…。

    こちらでもオーバーフローについては懐疑でしたが、
    その場合、何かしらの情報(メッセージ、落ちる、エラー、イベント)があるという
    認識でした。。
    さっぱりです‥。
記事No.81781 のレス /過去ログ140より / 関連記事表示
削除チェック/

■81933  Re[18]: DataSetの破棄について
□投稿者/ 魔界の仮面弁士 -(2016/11/24(Thu) 16:29:18)
    No81931 (sk さん) に返信
    > こちらでもオーバーフローについては懐疑でしたが、
    > その場合、何かしらの情報(メッセージ、落ちる、エラー、イベント)があるという
    > 認識でした。。

    処理の高速化のため、オーバーフローチェックが省略されているのかも知れません。

    https://msdn.microsoft.com/ja-jp/library/system.reflection.emit.opcodes.add%28vs.90%29.aspx

    》 オーバーフローは、整数演算については検出されません。
    》 整数加算では、飽和させず、ラップします。たとえば、
    》 8 ビット整数で value1 が 255 に、value2 が 1 に設定されている場合、
    》 ラップされた結果は 256 ではなく 0 になります。



    VB の場合、[コンパイラの詳細設定]-[整数オーバーフローのチェックを解除]を
    有効にしておくと、下記のコードが System.OverflowException を発することなく、
    「4294967294」「4294967295」「0」「1」「2」と表示されるようになります。

    Dim counter = &HFFFFFFCEui
    For i = 48ui To 52ui
      Console.WriteLine(counter + i)
    Next



    C# にも同様のコンパイラオプションがありますが、それとは別に、
    checked / unchecked という構文を持っており、任意の箇所で局所的に
    演算のオーバーフローチェックの有無を切り替えられるようになっています。


    uint counter = 0xFFFFFFCEu;
    for (uint i = 48u; i <= 52u; i++) unchecked {
      Console.WriteLine(counter + i);
    }


    そして IL レベルにおいても、オーバーフローを検出しない加算命令
    0x58 (add) とは別に、オーバーフローチェック付きの加算命令
    0xd6 (add.ovf) および 0xd7 (add.ovf.un) が存在してます。


    ※型付きの DataSet(または DataTable)の InitClass メソッドの先で
     どのような呼び出しが行われているのかは未調査です。
記事No.81781 のレス /過去ログ140より / 関連記事表示
削除チェック/

■93572  Re[2]: 24bit画像をインデックス画像化する方法
□投稿者/ 烏賊 -(2019/12/22(Sun) 22:07:20)
    ありがとうございます。
    
    デフォルトではそのような機能はないのですね。
    
    検索すると高速な変換コードが見つかりました。
    
    http://www.wischik.com/lu/programmer/1bpp.html
    
    これをVBに書き換えてみたのですが
    エラーなくインデックス画像は出力されるのですが、
    元画像と比べてかなり暗い色になってしまいます。
    
    どこに変換ミスがあるか見ていただけないでしょうか?
    
    
    
    
    
        Private Function CopyToBpp(ByVal b As System.Drawing.Bitmap, ByVal bpp As Integer) As System.Drawing.Bitmap
            If ((bpp <> 1) _
                         AndAlso (bpp <> 8)) Then
                Throw New System.ArgumentException("1 or 8", "bpp")
            End If
    
            Dim h As Integer = b.Height
            Dim w As Integer = b.Width
            Dim hbm As IntPtr = b.GetHbitmap
            ' this is step (1)
            '
            ' Step (2): create the monochrome bitmap.
            ' "BITMAPINFO" is an interop-struct which we define below.
            ' In GDI terms, it's a BITMAPHEADERINFO followed by an array of two RGBQUADs
            Dim bmi As BITMAPINFO = New BITMAPINFO
            bmi.biSize = 40
            ' the size of the BITMAPHEADERINFO struct
            bmi.biWidth = w
            bmi.biHeight = h
            bmi.biPlanes = 1
            ' "planes" are confusing. We always use just 1. Read MSDN for more info.
            bmi.biBitCount = CType(bpp, Short)
            ' ie. 1bpp or 8bpp
            bmi.biCompression = BI_RGB
            ' ie. the pixels in our RGBQUAD table are stored as RGBs, not palette indexes
            bmi.biSizeImage = CType((((w + 7) And 4294967288) * (h / 8)), UInteger)
            bmi.biXPelsPerMeter = 1000000
            ' not really important
            bmi.biYPelsPerMeter = 1000000
            ' not really important
            ' Now for the colour table.
            Dim ncols As UInteger = CUInt(1 + bpp)
            ' 2 colours for 1bpp; 256 colours for 8bpp
            bmi.biClrUsed = ncols
            bmi.biClrImportant = ncols
            bmi.cols = New UInteger((256) - 1) {}
            ' The structure always has fixed size 256, even if we end up using fewer colours
            If (bpp = 1) Then
                bmi.cols(0) = MAKERGB(0, 0, 0)
                bmi.cols(1) = MAKERGB(255, 255, 255)
            Else
                Dim i As Integer = 0
                Do While (i < ncols)
                    bmi.cols(i) = MAKERGB(i, i, i)
                    i = (i + 1)
                Loop
    
            End If
    
            ' For 8bpp we've created an palette with just greyscale colours.
            ' You can set up any palette you want here. Here are some possibilities:
            ' greyscale: for (int i=0; i<256; i++) bmi.cols[i]=MAKERGB(i,i,i);
            ' rainbow: bmi.biClrUsed=216; bmi.biClrImportant=216; int[] colv=new int[6]{0,51,102,153,204,255};
            '          for (int i=0; i<216; i++) bmi.cols[i]=MAKERGB(colv[i/36],colv[(i/6)%6],colv[i%6]);
            ' optimal: a difficult topic: http://en.wikipedia.org/wiki/Color_quantization
            ' 
            ' Now create the indexed bitmap "hbm0"
            Dim bits0 As IntPtr
            ' not used for our purposes. It returns a pointer to the raw bits that make up the bitmap.
            Dim hbm0 As IntPtr = CreateDIBSection(IntPtr.Zero, bmi, DIB_RGB_COLORS, bits0, IntPtr.Zero, 0)
            '
            ' Step (3): use GDI's BitBlt function to copy from original hbitmap into monocrhome bitmap
            ' GDI programming is kind of confusing... nb. The GDI equivalent of "Graphics" is called a "DC".
            Dim sdc As IntPtr = GetDC(IntPtr.Zero)
            ' First we obtain the DC for the screen
            ' Next, create a DC for the original hbitmap
            Dim hdc As IntPtr = CreateCompatibleDC(sdc)
            SelectObject(hdc, hbm)
            ' and create a DC for the monochrome hbitmap
            Dim hdc0 As IntPtr = CreateCompatibleDC(sdc)
            SelectObject(hdc0, hbm0)
            ' Now we can do the BitBlt:
            BitBlt(hdc0, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
            ' Step (4): convert this monochrome hbitmap back into a Bitmap:
            Dim b0 As System.Drawing.Bitmap = System.Drawing.Bitmap.FromHbitmap(hbm0)
            '
            ' Finally some cleanup.
            DeleteDC(hdc)
            DeleteDC(hdc0)
            ReleaseDC(IntPtr.Zero, sdc)
            DeleteObject(hbm)
            DeleteObject(hbm0)
            '
            Return b0
        End Function
    
        <System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)>
        Public Structure BITMAPINFO
    
            Public biSize As UInteger
            Public biWidth As Integer
            Public biHeight As Integer
            Public biPlanes As Short
            Public biBitCount As Short
            Public biCompression As UInteger
            Public biSizeImage As UInteger
            Public biXPelsPerMeter As Integer
            Public biYPelsPerMeter As Integer
            Public biClrUsed As UInteger
            Public biClrImportant As UInteger
    
            <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=256)>
            Public cols() As UInteger
        End Structure
    
    
        Public Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As IntPtr) As Boolean
    
        Public Declare Function GetDC Lib "user32.dll" (ByVal hwnd As IntPtr) As IntPtr
    
        Public Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hdc As IntPtr) As IntPtr
    
        Public Declare Function ReleaseDC Lib "user32.dll" (ByVal hwnd As IntPtr, ByVal hdc As IntPtr) As Integer
    
        Public Declare Function DeleteDC Lib "gdi32.dll" (ByVal hdc As IntPtr) As Integer
    
        Public Declare Function SelectObject Lib "gdi32.dll" (ByVal hdc As IntPtr, ByVal hgdiobj As IntPtr) As IntPtr
    
        Public Declare Function BitBlt Lib "gdi32.dll" (ByVal hdcDst As IntPtr, ByVal xDst As Integer, ByVal yDst As Integer, ByVal w As Integer, ByVal h As Integer, ByVal hdcSrc As IntPtr, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal rop As Integer) As Integer
    
        Private SRCCOPY As Integer = 13369376
    
        Private Declare Function CreateDIBSection Lib "gdi32.dll" (ByVal hdc As IntPtr, ByRef bmi As BITMAPINFO, ByVal Usage As UInteger, ByRef bits As IntPtr, ByVal hSection As IntPtr, ByVal dwOffset As UInteger) As IntPtr
    
        Private BI_RGB As UInteger = 0
    
        Private DIB_RGB_COLORS As UInteger = 0
    
        Private Function MAKERGB(ByVal r As Integer, ByVal g As Integer, ByVal b As Integer) As UInteger
            Return (CType((b And 255), UInteger) _
                         Or (CType(((r And 255) _
                         + 8), UInteger) Or CType(((g And 255) _
                         + 16), UInteger)))
        End Function
    
    
    
    
記事No.93568 のレス /過去ログ162より / 関連記事表示
削除チェック/

■94967  Re[1]: SelectionFontの英字・ひらがな混合の場合について
□投稿者/ 魔界の仮面弁士 -(2020/06/07(Sun) 13:12:17)
    No94964 (Visual C#初心者 さん) に返信
    > SelectionFont.Bold,あるいはUnderlineでフォントスタイルで判断し,
    (中略)
    > しかしSelection.Boldの時にnullを返してしまうので,
    > 何かいい方法はありますでしょうか?

    SelectionFont.Bold および
    Selection.Bold がある何か…に対するフォント操作という点は理解しました。

    しかし前提条件がゴッソリ抜け落ちているので、状況を把握しにくいです。
    C# に関する質問…というのは分かりますが、一体何の話でしょうか。(^_^;)



    最初は Microsoft Word のオートメーション操作かと思いましたが、
    Word には SelectionFont というプロパティがありません。(Selection ならある)

    System.Windows.Forms.RichTextBox ではその逆で、
    Selection プロパティが存在しません。(SelectionFont ならある)

    System.Windows.Controls.RichTextBox だとしたら、Selection フォントが無く、
    しかも Selection プロパティが返す TextSelection 型に Bold プロパティがありません。


    ActiveX 版の RichTextBox が相手の場合は、フォント混在であろうと、
     axRichTextBox1.SelBold = true;
     axRichTextBox1.SelUnderline = true;
    で処理できますが…こちらは Selection も SelectionFont もありません。
記事No.94964 のレス /過去ログ164より / 関連記事表示
削除チェック/

■94968  Re[2]: SelectionFontの英字・ひらがな混合の場合について
□投稿者/ Visual C#初心者 -(2020/06/07(Sun) 13:43:15)
    No94967 (魔界の仮面弁士 さん) に返信
    > ■No94964 (Visual C#初心者 さん) に返信
    >>SelectionFont.Bold,あるいはUnderlineでフォントスタイルで判断し,
    > (中略)
    >>しかしSelection.Boldの時にnullを返してしまうので,
    >>何かいい方法はありますでしょうか?
    >
    > SelectionFont.Bold および
    > Selection.Bold がある何か…に対するフォント操作という点は理解しました。
    >
    > しかし前提条件がゴッソリ抜け落ちているので、状況を把握しにくいです。
    > C# に関する質問…というのは分かりますが、一体何の話でしょうか。(^_^;)
    >
    >
    >
    > 最初は Microsoft Word のオートメーション操作かと思いましたが、
    > Word には SelectionFont というプロパティがありません。(Selection ならある)
    >
    > System.Windows.Forms.RichTextBox ではその逆で、
    > Selection プロパティが存在しません。(SelectionFont ならある)
    >
    > System.Windows.Controls.RichTextBox だとしたら、Selection フォントが無く、
    > しかも Selection プロパティが返す TextSelection 型に Bold プロパティがありません。
    >
    >
    > ActiveX 版の RichTextBox が相手の場合は、フォント混在であろうと、
    >  axRichTextBox1.SelBold = true;
    >  axRichTextBox1.SelUnderline = true;
    > で処理できますが…こちらは Selection も SelectionFont もありません。

    ご返信ありがとうございます。
    こちらの説明不足と記載ミスがあり、失礼致しました。

    まず、開発環境としてはVisual C#のwinFormです。
    Richtextbox上のフォント混在文字列を選択した状態で
    太字(下線)の有無をobj.SelectionFont.Bold(Underline)で
    判定したいという趣旨になります。

    上記で
    >>しかしSelection.Boldの時にnullを返してしまうので,
    と記載してしまいましたが正しくはSelectionFont.Bold
    になります。

    伺いたい内容としては、SelectionFont.Boldで太字判定
    させたくても、フォント混在の場合はnullを返すので、
    SelectionFont以外で良い方法があれば教えて頂ければ
    ということになります。

    以上になります。
記事No.94964 のレス /過去ログ164より / 関連記事表示
削除チェック/



<< 0 >>

パスワード/

- Child Tree -