posted by bluelimn 2014.03.28 12:14

    Rectangle backup;

        private void checkBox_mouse_tracking_CheckedChanged(object sender, EventArgs e)

        {

            if (checkBox_mouse_tracking.Checked)

            {

                backup = Cursor.Clip;

                this.Cursor = new Cursor(Cursor.Current.Handle);

                Cursor.Position = new Point(this.Location.X+ label_mouse_tracking.Location.X , this.Location.Y + label_mouse_tracking.Location.Y);

                Point p = new Point(this.Location.X + label_mouse_tracking.Location.X+7, this.Location.Y + label_mouse_tracking.Location.Y+30);

                

                Cursor.Clip = new Rectangle(p, label_mouse_tracking.Size);

            }

            else

            {

                Cursor.Clip = backup;

            }

            

        }



    }

posted by bluelimn 2010.07.29 20:14
public static void SetSleepTime(int sec)
        {
            RegistryKey driverKeyRoot = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\Power\\Timeouts", true);
            driverKeyRoot.SetValue("ACUserIdle", sec, RegistryValueKind.DWord);
            driverKeyRoot.SetValue("BattUserIdle", sec, RegistryValueKind.DWord);
            driverKeyRoot.Close();
        }

분명 레지스트리는 바로바로 바뀌는데
sleep time은 한번에 적용되지 않는 경우가 있다.
왜 그럴까?
posted by bluelimn 2010.06.27 19:25

C언어에서 sendMessage()함수를 사용하는 것처럼 C#에서도 구현하고 싶은데 이것이 또 그냥 되지는 않더라.


[DllImport("coredll.dll", CharSet = CharSet.Auto)]
        static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

이런 식으로 함수원형을 선언했다.

이렇게 구현하여 보내는 Message는 WndProc함수를 이용하여 확인할 수 있는데 .net framework에서는 Form class에서 지원하지만  compactframework에서는 사용할 수 없다.

MessageWindow를 이용하여 우회적으로 사용할 수는 있다.

protected override void WndProc(ref Message msg)
        {
            switch (msg.Msg)
            {
                case (MSG.Message1):
                    Console.WriteLine("Message1");
                    Program.mainform.Function1();
                    break;
                case (MSG.Message2):
                    Console.WriteLine("in WndProc Message2");
                    switch (MSG.WParam.ToInt32())
                    {
                        case START:
                            if (Program.mainform.CLI_Flag == true)
                            {
                                Program.mainform.AbortThread();
                            }
                            Program.mainform.g_bStop = true;
                            break;
                        case PAUSE:
                            break;
                        case RESTART:
                            break;
                        case END:
                            Console.WriteLine("END");
                            if (Program.mainform.CLI_Flag == true)
                            {
                                Program.mainform.CreateThread();
                            }
                            break;
                        case ERROR:
                            break;
                    }                    
                    //Do something here
                    break;
            }

            // call the base class WndProc for default message handling
            base.WndProc(ref msg);
        }
    }

다음은 message를 보내는 부분이다
SendMessage(winproc.Hwnd, MSG.Message1, IntPtr.Zero, IntPtr.Zero);

핸들러를 IntPtr형식으로 주게되면 dll에서 메시지를 보내는 것도 동일하게 받아올 수 있다.

posted by bluelimn 2010.06.26 00:02

[DllImport("coredll.dll", CharSet = CharSet.Unicode)]
        private static extern uint RegOpenKeyEx(
            uint HKEY,
            string lpSubKey,
            int ulOptions,
            uint samDesired,
            out uint phkResult);

        [DllImport("coredll.dll", CharSet = CharSet.Unicode)]
        private static extern uint RegQueryValueEx(
            uint hKey,
            string lpValueName,
            int lpReserved,
            ref int lpType,
            StringBuilder lpData,
            ref int lpcbData);

        [DllImport("coredll.dll")]
        private static extern int RegSetValueEx(
            uint hKey,
            [MarshalAs(UnmanagedType.LPArray)] byte[] lpValueName,
            int Reserved,
            Microsoft.Win32.RegistryValueKind dwType,
            [MarshalAs(UnmanagedType.LPArray)] byte[] lpData,
            int cbData);


        [DllImport("coredll.dll")]
        private static extern int RegCloseKey(uint hkey);

그런데 바로 적용되는 것이 있는가하면 재부팅 후 적용이 되는 녀석들도 많아 의도하는데로 사용하진 못했다.

posted by bluelimn 2010.06.26 00:01

private const uint HKEY_LOCAL_MACHINE = 0x80000002;

        [DllImport("CoreDll.dll", SetLastError = true)]
        private static extern IntPtr GetModuleHandle(IntPtr ModuleName);

        [DllImport("CoreDll.dll", SetLastError = true)]
        private static extern Int32 GetModuleFileName(IntPtr hModule, StringBuilder ModuleName, Int32 cch);


        public static string GetEntryAssembly()
        {
            StringBuilder fn = null;
            IntPtr hModule = GetModuleHandle(IntPtr.Zero);
            if (IntPtr.Zero != hModule)
            {
                fn = new StringBuilder(255);
                if (0 == GetModuleFileName(hModule, fn, fn.Capacity))
                    return null;
            }
            return fn.ToString();
        }

        public static string GetEntryDirectory()
        {
            string assembly = GetEntryAssembly();

            if (assembly == null)
                return null;

            int crop = assembly.LastIndexOf("\\");

            if (crop > 0)
                assembly = assembly.Remove(crop, assembly.Length - crop);

            return assembly;
        }

==========================================================
compack framework에서는 getCurrentDirectory()같은 함수를 사용할 수 없다.
하지만 돌려서 사용하는 함수를 구현해서 쓸 수 있다.

posted by bluelimn 2010.06.05 14:56

일반적인 .net framework에 비해 compack framework는 기능 제한이 너무 심하다.

PDA, 모바일용 프로그램을 작성할 때 사용되는데 특히 UI를 이쁘게 꾸미는 부분이 많이 막혀있다. 임베디드용이기 때문에 리소스를 많이 사용하는 것을 막아 여러 프로그램이 실행되더라도 안정적으로 돌아가게 할 수 있도록 프로그래머를 길들인다는 정책이다.

하지만 예측이란 것은 그 시점의 환경을 중심으로 하는 것이기 때문에 지금과 같이 하드웨어 환경이 좋아진 임베디드라면 그러한 제약을 오히려 풀어놓는 것이 맞다고 생각한다.


6월엔 WindowsCE 환경의 compact framework에서 작성한 프로그램을 가지고 사용법을 정리해봐야 겠다.

posted by bluelimn 2008.08.21 22:02

DataGridViewCheckBoxColumn chkBillable = new DataGridViewCheckBoxColumn();

chkBillable.Name = "colTimeSheetBillable";

chkBillable.HeaderText = "Billable";

chkBillable.DataPropertyName = "TimeSheetBillable";

chkBillable.ReadOnly = true;

dataGridTimesheet.Columns.Add(chkBillable);

posted by bluelimn 2008.02.26 22:02

Today we shipped Visual Studio 2008 and .NET 3.5.  You can download the final release using one of the links below:

  • If you are a MSDN subscriber, you can download your copy from the MSDN subscription site (note: some of the builds are just finishing being uploaded now - so check back later during the day if you don't see it yet).

  • If you are a non-MSDN subscriber, you can download a 90-day free trial edition of Visual Studio 2008 Team Suite here.  A 90-day trial edition of Visual Studio 2008 Professional (which will be a slightly smaller download) will be available next week.  A 90-day free trial edition of Team Foundation Server can also be downloaded here.

  • If you want to use the free Visual Studio 2008 Express editions (which are much smaller and totally free), you can download them here

  • If you want to just install the .NET Framework 3.5 runtime, you can download it here.

Quick Tour of Some of the New Features

Visual Studio 2008 and .NET 3.5 contain a ton of new functionality and improvements.  Below are links to blog posts I've done myself as well as links to videos you can watch to learn more about it:

VS 2008 Multi-Targeting Support

VS 2008 enables you to build applications that target multiple versions of the .NET Framework.  This means you can use VS 2008 to open, edit and build existing .NET 2.0 and ASP.NET 2.0 applications (including ASP.NET 2.0 applications using ASP.NET AJAX 1.0), and continue to deploy these application on .NET 2.0 machines.  You can learn more about how this works from my blog post here:

ASP.NET AJAX and JavaScript Support

.NET 3.5 has ASP.NET AJAX built-in (no separate download required).  In addition to including all of the features in ASP.NET AJAX 1.0, ASP.NET 3.5 also now includes richer support for UpdatePanels integrating with WebParts, ASP.NET AJAX integration with controls like <asp:menu> and <asp:treeview>, WCF support for JSON, and many other AJAX improvements.

VS 2008 and Visual Web Developer 2008 also now have great support for integrating JavaScript and AJAX into your applications.  You can learn more about this from my blog posts here:

You can watch some videos that discuss ASP.NET AJAX and Visual Studio 2008 support for it here

I also highly recommend the excellent ASP.NET AJAX in Action book to learn more about ASP.NET AJAX (both client-side and server-side).

VS 2008 Web Designer and CSS Support

VS 2008 and Visual Web Developer 2008 Express includes a significantly improved HTML web designer (the same one that ships with Expression Web).  This delivers support for split-view editing, nested master pages, and great CSS integration.  Below are some articles I've written that discuss this more:

ASP.NET 3.5 also has a new <asp:ListView> control that provides the ability to perform rich data scenarios with total control over the markup.  It works nicely with the new CSS support in VS 2008.  You can learn more about it from my article here:

You can watch some videos that discuss the new Visual Studio 2008 web designer features and the new ListView/DataPager controls here

Language Improvements and LINQ

The new VB and C# compilers in VS 2008 deliver significant improvements to the languages.  Both add functional programming concepts that enable you to write cleaner, terser, and more expressive code.  These features also enable a new programming model we call LINQ (language integrated query) that makes querying and working with data a first-class programming concept with .NET. 

Below are some of the articles I've written that explore these new language features using C#:

Here are a few additional blog posts I've written that show off some of the new VS 2008 code editing support and some cool ways to use these new language features:

The Visual Basic team has also created some great free videos that cover LINQ.  You can watch them here.

Data Access Improvements with LINQ to SQL

LINQ to SQL is a built-in OR/M (object relational mapper) in .NET 3.5.  It enables you to model relational databases using a .NET object model.  You can then query the database using LINQ, as well as update/insert/delete data from it.  LINQ to SQL fully supports transactions, views, and stored procedures.  It also provides an easy way to integrate business logic and validation rules into your data model.  Below are some of the articles I've written that explore how to use it:

I think you'll find that LINQ and LINQ to SQL makes it much easier to build much cleaner data models, and write much cleaner data code.  I'll be adding more posts to my LINQ to SQL series in the weeks and months ahead (sorry for the delay in finishing them earlier - so much to-do and so little time to-do it all!).

Scott Stanfield is also working on creating some great LINQ to SQL videos for the www.asp.net site based on my article series above (all videos are in both VB and C#).  You can watch the first 4 videos in this series here.

Browsing the .NET Framework Library Source using Visual Studio

As I blogged a few weeks ago, we will be releasing a reference version of the .NET Framework library source code as part of this release.  Visual Studio 2008 has built-in debugger support to automatically step-into and debug this code on demand (VS 2008 can pull down the source for the appropriate .NET Framework library file automatically for you).

We are deploying the source servers to enable this right now, and will be publishing the steps to turn this feature on in the next few weeks.

Lots of other improvements

The list above is only a small set of the improvements coming.  For client development VS 2008 includes WPF designer and project support.  ClickOnce and WPF XBAPs now work with FireFox.  WinForms and WPF projects can also now use the ASP.NET Application Services (Membership, Roles, Profile) for roaming user data. 

Office development is much richer - including support for integrating with the Office 2007 ribbon, and with Outlook.  Visual Studio Tools for Office support is also now built-into Visual Studio (you no longer need to buy a separate product).

New WCF and Workflow projects and designers are now included in VS 2008.  Unit testing support is now much faster and included in VS Professional (and no longer just VSTS).  Continuous Integration support is now built-in with TFS.  AJAX web testing (unit and load) is now supported in the VS Test SKU.  And there is much, much more...

Installation Suggestions

People often ask me for suggestions on how best to upgrade from previous betas of Visual Studio 2008.  In general I'd recommend uninstalling the Beta2 bits explicitly.  As part of this you should uninstall Visual Studio 2008 Beta2, .NET Framework Beta2, as well as the Visual Studio Web Authoring Component (these are all separate installs and need to be uninstalled separately).  I then usually recommend rebooting the machine after uninstalling just to make sure everything is clean before you kick off the new install.  You can then install the final release of VS 2008 and .NET 3.5 on the machine.

Once installed, I usually recommend explicitly running the Tools->Import and Export Settings menu option, choosing the "Reset Settings" option, and then re-pick your preferred profile.  This helps ensure that older settings from the Beta2 release are no longer around (and sometimes seems to help with performance).

Note that VS 2008 runs side-by-side with VS 2005 - so it is totally fine to have both on the same machine (you will not have any problems with them on the same box).

Silverlight Tools and VS Web Deployment Project Add-Ins

Two popular add-ins to Visual Studio are not yet available to download for the final VS 2008 release.  These are the Silverlight 1.1 Tools Alpha for Visual Studio and the Web Deployment Project add-in for Visual Studio.  Our hope is to post updates to both of them to work with the final VS 2008 release in the next two weeks.  If you are doing Silverlight 1.1 development using VS 2008 Beta2 you'll want to stick with with VS 2008 Beta2 until this updated Silverlight Tools Add-In is available. 

Hope this helps,

Scott

posted by bluelimn 2008.02.26 21:59

작년 10월 초에 프레임워크 소스를 공개할 거라는 예고 포스팅이 있었죠.
그 포스트를 보고 굉장히 흥분했던 기억이 떠오르네요.
언제쯤 가능할지 며칠동안 Scott의 블로그를 들락날락 거리다가 지쳐 잊고 있었는데 말이죠.

드뎌 기다리던 .NET Framework Library 소스가 공개되었습니다.
원문 링크는 다음과 같구요.
.NET Framework Library Source Code now available

살펴보니 많은 부분이 공개되었네요.

.NET Base Class Libraries 뿐만 아니라 ASP.NET, WinForms, WPF, ADO.NET, XML이 디버깅 가능하구요,

LINQ와 WCF, Workflow 도 공개하기 위해 작업 중이라고 하네요.
가능하게 되면 추후 블로그에 포스팅한다고 하니 소식이 뜨면 다시 살펴보겠습니다.

우선 .NET Framework 소스 코드를 디버깅하기 위한 설정은 다음과 같습니다.

1. Visual Studio 2008 Trial 버전을 설치하구요. MS에서 다운로드 받을 수 있습니다.

2. Visual Studio 2008 QFE를 설치합니다.

3. Visual Studio 2008을 실행한 후 Tools 메뉴의 Options-> Debugging-> General 탭을 열고
    'Enable Just My Code' 체크 해제, 'Enable Source Server Support' 체크 설정합니다.


4. Options-> Debugging-> Symbols 탭을 열고
  a) Symbol file(.pdb) locations 리스트에
      'http://referencesource.microsoft.com/symbols' 링크를 추가합니다.
  b) Cache symbols from symbol servers to this directory에 윈도우에
      현재 로그인한 계정으로 읽고 쓸수 있는 임의의 폴더를 만들어 선택하도록 합니다.
  c) Search the above locations only when symbols are loaded manually 항목을 체크합니다.




설정이 모두 완료되었습니다.

이제 디버깅이 잘 되는지 한번 살펴보죠.

1. 윈폼 어플리케이션 프로젝트를 하나 만듭니다.

2. 폼에 버튼을 두고 Click 이벤트에 메세지박스를 출력하는 코드를 입력하고 브레이크 포인트를 설정합니다.


3. 'F5'를 눌러 디버깅을 시작합니다. 윈폼이 뜨면 버튼을 클릭합니다.

4. 브레이크 포인트에서 Call Stack 윈도우로 이동한 후 팝업메뉴에서 Load Symbols 메뉴를 선택합니다.


5. 그럼 다음과 같이 비활성화 되어 있던 항목이 활성화되면서 디버깅이 가능하게 되는 것을 확인할 수 있습니다.

6. 'F11'을 눌러 MessageBox.Show()메서드 안으로 디버깅을 시도하게 되면 다음과 같이 System.Windows.Forms.MessageBox 클랙스를 디버깅할 수 있게 됩니다.


와우~...기분이 묘해지는군요.

이상으로 간단하게 살펴보았습니다.

더 자세한 내용은 다음 포스트를 참조해 주세요.
아래 링크는 원문 포스트입니다.
Configuring Visual Studio to Debug .NET Framework Source Code

이렇게 .NET Framework 라이브러리 소스가 공개되는 것이 우리에게 어떤 의미일까요?
좀 더 차분하게 고민해보고 많은 것을 얻을 수 있는 기회가 되었으면 좋겠다는 생각을 해봅니다.

== 어디선가 불펌했는데 기억이 안나서 출처를 못밝힙니다.. 혹시나 어디서 나온 건지 아는 사람은 꼬릿말 남겨주세요..