기본 콘텐츠로 건너뛰기

글

프린터 속성 설정하기

아래는 프린터 속성을 설정하는 함수입니다. 원문보기 #include <WinSpool.h> /** @brief set printer property @author humkyung @date 2013.11.06 @param pPrinterName @param dmType @param dmValue **/ STDMETHODIMP CISODwgLib4IDCS::SetPrinterProperty(BSTR pPrinterName , SHORT dmType, SHORT dmValue, VARIANT_BOOL* ret) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CString sPrinterName(pPrinterName); (*ret) = VARIANT_TRUE; ////////////////////////////////////////////////////////////////////////// HANDLE hPrinter = NULL; DWORD dwNeeded = 0; PRINTER_INFO_2 *pi2 = NULL; DEVMODE *pDevMode = NULL; PRINTER_DEFAULTS pd; BOOL bFlag; LONG lFlag; // Open printer handle (on Windows NT, you need full-access because you // will eventually use SetPrinter)... ZeroMemory(&pd, sizeof(pd)); pd.DesiredAccess = PRINTER_ALL_ACCESS; bFlag = OpenPrinter(LPSTR(sPrinterName.operator LPCSTR()) , &hPrinter, &pd); if (!bFlag || (hPrinter == NULL)) return FALSE; // The first GetPrinter tells ...

마이크로스테이션 V8의 Batch Process를 이용한 Dwg 변환

이 매크로를 만들게 된 이유는 Batch Converter로 변환 시 Dgn에서 Off된 Level도 Dwg로 변환 시 모두 On이 되기 때문입니다. Dgn에서 Off된 Level를 찾아 저장 후, Dwg로 변환하고 나서 저장한 Level과 같은 이름의 Level를 찾아 Off시키도록 했습니다. - Macro File - Sub ConvertWithoutUnvisibleLevel ( ) RemoveLevel = False Dim oLevels As Levels Dim oLevel As Level Dim oView As View Dim oOffLevel ( 10 ) As String Dim counter ( 2 ) As Integer , iOffLevelCount Set oLevels = ActiveDesignFile . Levels Set oView = ActiveDesignFile . Views ( 1 ) counter ( 0 ) = 0 iOffLevelCount = 0 Do While counter ( 0 ) < oLevels . Count counter ( 0 ) = counter ( 0 ) + 1 Set oLevel = oLevels . Item ( counter ( 0 ) ) If True < > oLevel . IsDisplayedInView ( oView ) Then oOffLevel ( iOffLevelCount ) = oLevel . Name iOffLevelCount = iOffLevelCount + 1 End If Loop ...

이미지 파일을 알파채널을 가진 BMP 파일로 변환

아래와 같이 간단하게 할 수 있습니다. if (5 == args.Length) { string sInutFilePath = args[0]; string sOutputFilePath = args[1]; int iRed = Convert.ToInt32(args[2]); int iGreen = Convert.ToInt32(args[3]); int iBlue = Convert.ToInt32(args[4]); Bitmap bmp = Image.FromFile(sInutFilePath) as Bitmap; bmp.MakeTransparent(Color.FromArgb(iRed, iGreen, iBlue)); bmp.Save(sOutputFilePath, ImageFormat.Bmp); } else { Console.WriteLine("Usage: png2bmp32 "); }

MessageBox with custom icon

MSGBOXPARAMS msgbox = { 0 } ; msgbox . cbSize = sizeof ( msgbox ) ; msgbox . dwStyle = MB_USERICON | MB_OK ; // MB_USERICON - flag for "lpszIcon" msgbox . hInstance = GetModuleHandle ( 0 ) ; // handle of file with icon msgbox . hwndOwner = hWnd ; // parent window msgbox . lpszIcon = ( LPTSTR ) IDI_ICOID ; // ID of icon msgbox . lpszCaption = " Caption " ; msgbox . lpszText = " MessageBox with user icon " ; MessageBoxIndirect ( & msgbox ) ;

Val 함수 버그

VB는 거의 사용하지 않는데, 문의가 와서 확인을 해보니 아래와 같이 Val 함수 버그가 있었습니다. Val ( "5D1" ) 결과값을 5로 기대하겠지만 Val 함수는 50을 리턴합니다. 즉 이러한 문제를 피하기 위해 하는 수 없이 함수를 만들어 사용해야만 합니다. Function myInt ( s As String ) As Integer For i = 1 To Len ( s ) If IsAlpha ( Mid ( s , i , 1 ) ) Then Exit For End If Next If i > 1 Then s = Mid ( s , 1 , i - 1 ) End If myInt = Val ( s ) End Function Function IsAlpha ( s As String ) As Boolean Dim i As Integer Dim ch As Byte IsAlpha = True For i = 1 To Len ( s ) ch = Asc ( UCase $ ( Mid ( s , i , 1 ) ) ) If Not ( ( ch > = 65 ) And ( ch < = 90 ) ) Then IsAlpha = False Exit For End If Next i End Function --- Val 에러를 방지하는 방법 Many programmers use VB's Val() function to convert user inputted strings into numbers. This useful function returns zero (0) f...

MDL(USTN J) 프로그래밍시 유의 사항

J버전용 MDL 프로그램을 개발할 때 편집기를 VS를 사용하는데, 일반적으로 MDL 소스 파일의 확장자가 .mc라 편집기에서 문법 강조가 되지 않아 확장자를 .c로 바꾸어 사용 했습니다. 지금껏 잘 사용하다가 어떤 프로그램을 개발할때 MKE 파일에서 링크가 제대로 되지 않거나, 인클루드 구문이 제대로 기능을 발휘하지 못하는 현상이 발생했습니다. 한참을 그 원인을 찾다가 확장자 때문에 그렇다는 것을 알게되었습니다. 즉 확장자를 .c에서 .mc로 바꾸면 위의 문제가 사라지는 것이었습니다. 그런데 그렇게 하면 문법 강조를 사용할 수 없다는 사소한 문제가 있습니다. VS의 메뉴를 이것저것 찾아보다가 확장자를 추가해서 문법 강조를 사용할 수 있는 방법을 찾았습니다. Tools->Options

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은 이전 버젼과 바이너리 호환이 되지 않습니다. 따라서 이전 버젼으로 작성된 프로젝트는 소스를 다시 컴파일해야만 합니다.