기본 콘텐츠로 건너뛰기

글

keybd_event

도움글 keyd_event 함수를 통해서 keyboard를 이벤트를 생성할 수 있습니다. 자세한 내용은 위 도움글을 참조하시면 됩니다. void SendKeyIn ( const STRING_T & keyin ) { for ( int nIndex = 0 ; nIndex < int ( keyin . size ( ) ) ; + + nIndex ) { SHORT ch = VkKeyScan ( keyin [ nIndex ] ) ; if ( 1 = = HIBYTE ( ch ) ) { /// shift key press keybd_event ( VK_SHIFT , MapVirtualKey ( VK_SHIFT , 0 ) , 0 , 0 ) ; } keybd_event ( ch , MapVirtualKey ( keyin [ nIndex ] , 0 ) , 0 , 0 ) ; /// 0xE0 keybd_event ( ch , MapVirtualKey ( keyin [ nIndex ] , 0 ) , KEYEVENTF_KEYUP , 0 ) ; if ( 1 = = HIBYTE ( ch ) ) { /// shift key up keybd_event ( VK_SHIFT , MapVirtualKey ( VK_SHIFT , 0 ) , KEYEVENTF_KEYUP , 0 ) ; } } }

마이크로스테이션 V8의 Batch Process를 이용한 PDF 출력

마이크로스테이션 V8 의 Batch Process 를 이용한 Dgn->PDF 출력 첨부한 파일 (Command File) 을 로컬에 복사하세요 . 1.      Utility à Batch Process 를 클릭 2.      PDF 로 출력할 Dgn  파일을 추가 3.      첨부한 Command File 을 선택 4.      Batch Job 실행 5.      PDF 파일은 Adobe Acrobat 에서 설정한 Output Folder 에 생성이 됩니다 . --- Command File -- #---------------------------------------------------------------------- # #  Command file for batchprocess utility # #  This command file was originally copied from $(MS_DATA)cmdfiletemplate.txt. #  Command file information: #       - Lines that start with the '#' character are treated as comments and ignored. # #---------------------------------------------------------------------- fit view extended print attributes lineweights off # 레퍼런스등이 있을 수 있으므로 place fence allfiles 1...

How do you detect where two line segments intersect?

There’s a nice approach to this problem that uses vector cross products. Define the 2-dimensional vector cross product  v  ×  w  to be  v x w y  −  v y w x  (this is the magnitude of the 3-dimensional cross product). Suppose the two line segments run from  p  to  p  +  r  and from  q  to  q  +  s . Then any point on the first line is representable as  p  +  t   r  (for a scalar parameter  t ) and any point on the second line as  q  +  u   s  (for a scalar parameter  u ). The two lines intersect if we can find  t  and  u  such that: p  +  t   r  =  q  +  u   s Cross both sides with  s , getting ( p  +  t   r ) ×  s  = ( q  +  u   s ) ×  s And since  s  ×  s  =  0 , this means ...

VisualStudio 재배포판 설치여부 확인하기

원문 VC 8.0 Redistributables This function detects if VC++ 8.0 redistributables are installed on the machine ;------------------------------- ; Test if Visual Studio Redistributables 2005+ SP1 installed ; Returns -1 if there is no VC redistributables intstalled Function CheckVCRedist Push $R0 ClearErrors ReadRegDword $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{7299052b-02a4-4627-81f2-1818da5d550d}" "Version"  ; if VS 2005+ redist SP1 not installed, install it IfErrors 0 VSRedistInstalled StrCpy $R0 "-1" VSRedistInstalled: Exch $R0 FunctionEnd It should be noted that the DLLs could be installed even if the redistributable isn't installed. One example would be if the user has Visual Studios installed, then they have the dlls without the redist. Newer Visual Studio runtime versions: Visual Studio 2005, x86 SP1: ( 8.0.59193) "{837b34e3-7c30-493c-8f6a-2b0f04e2912c}" Visual Studio 2008, x86 S...

OpenCASCADE 6.6.0 빌드하기

1. 환경 변수 설정하기 OpenCASCADE 6.6.0은 이전 버젼과 바이너리 호환이 되지 않습니다. 따라서 이전 버젼으로 작성된 프로젝트는 소스를 다시 컴파일해야만 합니다.

도면을 PDF로 저장

SmartSketch는 도면을 PDF로 저장할 수 있는 함수를 제공하고 있습니다. void SaveAsPDF(string fileName, bool Bookmarks, PDFResolutionConstants Resolution, PDFColorModeConstants ColorMode, PDFJpegCompressionConstants JpegCompression, int SheetArraySize, object SheetArray); 다른 인자들은 쉽게 알수 있는데 제일 뒤 SheetArraySize , SheetArray가 뭔지 모호합니다. 느낌으로는 SmartSketch도 하나의 도면에 여러개의 Sheet를 가질 수 있으니, SheetArraySize는 Sheet의 갯수, SheetArray는 Sheet를 담은 배열이라 생각하고 값을 입력했더니 프로그램 오류가 발생했습니다. 그래서 궁리끝에 SheetArraySize에 0 , SheetArray에 null을 넘겨주니 에러없이 동작하였습니다. 아래는 PDF로 저장하는 예제 코드입니다. public bool SaveAsPDF(string sPDFFilePath , string sShaFilePath , ref string sLog) { var app = ComInterop.GetInstance<SmartSketch.Application>("SmartSketch.Application"); if (app != null) { try { app.Visible = true; /// Make application visible var doc = app.Documents.Open(sShaFilePath); /// Document Open doc.SaveAsPDF(sPDFFilePath, false, SmartSketch.PDFResolutionConstants.igPDFResolution1200DPI, SmartSketch.PDFColo...

리스트 뷰의 응용

원문보기 1. 콜백항목 리스트 뷰는 컨트롤이 자체적으로 데이터를 관리한다. 그러나 메모리의 낭비가 생기고 데이터를 따로 관리해야 함으로 대량의 데이터를 관리할 경우에는 콜백 항목으로 데이터를 관리하는게 좋다. 콜백항목은  응용프로그램이 직접 리스트 뷰의 데이터를 소유 하고 있다가 리스트 뷰가 출력 또는 정렬을 위해 데이터가  필요할 경우에만 데이터를 제공 해 주는 형식을 말한다. 일괄적으로 데이터를 관리할 수 있다는 점과 메모리가 이중으로 낭비되지 않는다는 장점이 있다. 1-1 콜백항목의 추가 콜백항목을 사용하기 위해서는 일단 항목(아이템)을 추가 할 때 문자열은  LPSTR_TEXTCALLBACK  형식으로, 이미지는  I_IMAGECALLBACK  형식으로 추가를 하게 되면 콜백항목으로 등록이 된다. ex) LVITEM lvi ; lvi . mask = LVIF_TEXT ; lvi . state = 0 ; lvi . stateMask = 0 ; lvi . iSubItem = 0 ; for ( int i = 0 ; i < 5 ; i + + ) { lvi . iItem = i ; lvi . pszText = LPSTR_TEXTCALLBACK ; ListView_InsertItem ( hListView , & lvi ) ; ListView_SetItemText ( hListView , i , 1 , LPSTR_TEXTCALLBACK ) ; ListView_SetItemText ( hListView , i , 2 , LPSTR_TEXTCALLBACK ) ; ListView_SetItemText ( hListView , i , 3 , LPSTR_TEXTCALLBACK ) ; } 1-2 콜백항목의 데이터 처리 콜백항...

MSTN VBA - Lession7(폴더 선택하기)

폴더를 선택하는 예제입니다. Dim MyBl As BrowseInfo Dim FList As Long Dim DirName As String Dim SelFolder As String DirName = Space(255) MyBl.sTitle = "Select Root Folder" MyBl.sDisplayName = Space(255) MyBl.ulFlags = Bif_ReturnOnlyFSDirs FList = SHBrowseForFolder(MyBl) SelFolder = SHGetPathFromIDList(FList, DirName) DirName = Left(DirName, InStr(1, DirName, Chr(0)) - 1) If DirName <> "" Then TextBoxFolder.Text = DirName Else TextBoxFolder.Text = "" End If

How to force C# .net app to run only one instance in Windows?

Single Application을 생성하는 예제입니다. [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern bool SetForegroundWindow(IntPtr hWnd); /// /// The main entry point for the application. /// [STAThread] static void Main() { bool createdNew = true; using (Mutex mutex = new Mutex(true, "MyApplicationName", out createdNew)) { if (createdNew) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } else { Process current = Process.GetCurrentProcess(); foreach (Process process in Process.GetProcessesByName(current.ProcessName)) { if (process.Id != current.Id) { SetForegroundWindow(process.MainWindowHandle); break; } } } } }

Resource Compiler Error RC2170 bitmap file filename is not in 3.00 format

출처 THE IMAGINATIONS | 수나미 원문 https://blog.naver.com/imanoos/114581059 Resource Compiler Error RC2170 bitmap file filename is not in 3.00 format 매뉴얼로 PNG파일을 추가했는데 이런 에러가 떴을 경우, .rc 파일을 코드보기로 열어서 해당 파일의 BITMAP이라고 지정된 부분을 PNG로 수정하고 다시 컴파일한다. 별의별 일들이 발생한다니까요~~~

요소의 잘못된 Range 수정하기

특정 요소의 Range가 잘못된 경우가 발생할 수 있습니다. 특히 3rd party 프로그램에서 생성된 파일일 경우.. 이때 Range를 수정하는 명령이 있습니다. mdl load fixrange filedesign 특정 폴더 안의 도면에 대해서 위 명령을 수행하는 매크로를 만들어 보겠습니다. Sub main() Dim S$ Dim One_File_List as String MbeSendCommand "mdl load fixrange" One_File_List = Dir$("C:\Temp" + "\*.*") Do While One_File_List <> "" MbeSendCommand "newfile " + One_File_List$ MbeSendCommand "filedesign" One_File_List = Dir$ Loop Close 'up to here End Sub

Polygon 해칭

주어진 정점으로 이루어진 Polygon을 해칭하는 예제입니다. inData는 "HATCHPLINE,0,0,0.1,0,0.1,0.1,0,0.1,0,0," 이런식으로 주어지면 됩니다. Private Sub drawHatchPline(ByVal inData As String) Dim m_oShapeElement As ShapeElement Dim m_Points() As Point3d Dim ptrn As CrossHatchPattern Dim vertices() As Point3d Dim tokens() As String Dim i As Integer, index As Integer index = 0 tokens = Split(inData, ",") ReDim Preserve m_Points(UBound(tokens) / 2) For i = 1 To UBound(tokens) m_Points(index) = Point3dFromXY(Val(tokens(i)), Val(tokens(i + 1))) i = i + 1 index = index + 1 Next Set m_oShapeElement = CreateShapeElement1(msv8Element, m_Points, msdFillModeNotFilled) ActiveModelReference.AddElement m_oShapeElement ' Use a CrossHatchPattern object to set up the parameters for ' the hatching operation. Set ptrn = CreateCrossHatchPattern(0.01, 0.01, Pi / 4, -Pi / 4) ver...

선택한 Text의 정보 출력

선택한 Text의 정보를 출력하는 예제입니다. Sub DisplaySelTextElement() Dim cim As CadInputMessage Dim oEnumerator As ElementEnumerator If Not ActiveModelReference.AnyElementsSelected Then ShowError "The macro requires a selection set" Exit Sub End If Set oEnumerator = ActiveModelReference.GetSelectedElements Do While oEnumerator.MoveNext Dim oElement As Element Set oElement = oEnumerator.Current If oElement.Type = msdElementTypeText Then ShowStatus oElement.AsTextElement.Text End If Loop End Sub