CFanatic

Go Back   CFanatic > Programming > Win32 Programming

Join CFanatic Forum Now

how to pass the arguments to procedure to close the window topic posted under Win32 Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 05-30-2007, 05:24 AM
Member
 
Join Date: May 2007
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
vidhya is on a distinguished road
| More
how to pass the arguments to procedure to close the window

hi,this is part of my code.in this code when i execute the code first time it will create one borderless window in which the command line arguments will scroll.when i execute the same code second time in presence of the previous banner running it should close the previous banner and open the new window and the arguments whatever i pass will scroll in that newly created banner.
i want single instance of banner. i also want to know how to pass the arguments to procedure.

part of code:

Code:
using std::string;

using namespace std;

WNDCLASSEX  WndCls;

HWND hwnd;

LRESULT CALLBACK WindProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
 
CString string1,string2="",string3="";

string pre_lines="";




LPWSTR *szArglist;		//holds commandline arguments
   int nArgs;
   int i,j,k,l;
  

INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine, int nCmdShow)
{
//string1.Format("%-0s",lpCmdLine);

    static char szAppName[] = "GDISuite";
    MSG         Msg;

    WndCls.cbSize        = sizeof(WndCls);
    WndCls.style         = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
    WndCls.lpfnWndProc   = WindProcedure;
    WndCls.cbClsExtra    = 0;
    WndCls.cbWndExtra    = 0;
    WndCls.hInstance     = hInstance;
    WndCls.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    WndCls.hCursor       = LoadCursor(NULL, IDC_ARROW);
    WndCls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    WndCls.lpszMenuName  = NULL;
    WndCls.lpszClassName = szAppName;
    WndCls.hIconSm       = LoadIcon(hInstance, IDI_APPLICATION);
    RegisterClassEx(&WndCls);


	//creates window

    CreateWindowEx(WS_EX_OVERLAPPEDWINDOW | WS_EX_TOPMOST,
                          szAppName,
                          "GDI Accessories and Tools",
                          WS_POPUPWINDOW | WS_VISIBLE,
                          0,
                          0,
                          1500,
                          50,
		NULL,
                          NULL,
                          hInstance,
                          NULL);

    while( GetMessage(&Msg, NULL, 0, 0) )
    {
        TranslateMessage(&Msg);
        DispatchMessage( &Msg);
    }

    return static_cast<int>(Msg.wParam);
}

LRESULT CALLBACK WindProcedure(HWND hWnd, UINT Msg,
			   WPARAM wParam, LPARAM lParam)
{
	HDC hDC;
         PAINTSTRUCT Ps;
		 int a;

	switch(Msg)
	{
	
	case WM_PAINT:

		szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);

		if( NULL == szArglist )
		{
			wprintf(L"CommandLineToArgvW failed\n");
			return 0;
		}

		if( (CString)szArglist[1]=="a")
		{
	
		/*if(FindWindow("szAppName","GDI Accessories and Tools")!=NULL)
		{
			DestroyWindow(hWnd);
		}*/
			
			ifstream myfile7;

			myfile7.open  ("C:\\cmd.txt"); 

			//sText="EOD has not been started yet";

			if(myfile7.is_open())

			{

		while (! myfile7.eof() )

		{

		       string pline="";

		      getline (myfile7,pline);

		       pre_lines+=(pline+"\n"); 

						
	            }

	}

			myfile7.close();

			for( i=2; i<nArgs; i++)
				{ 
					string1=(CString)szArglist[i];

					string2=string2+" "+string1;
				}


			CString str=pre_lines.c_str();
			string3=str+" "+string2;

			ofstream myfile4; 

					myfile4.open("C:\\cmd.txt");

					if (myfile4.is_open())

					{


				myfile4 << pre_lines << string(string2);

					}

					myfile4.close();

			
			do
				{
			hDC = BeginPaint(hWnd, &Ps);
			TextOut(hDC, 10, 1,"Priority 1 Issues:",20);

			for(a=1;a<1100;a++)
			{
					
		TextOut(hDC, a+10, 18,string2,string2.GetLength());
		EndPaint(hWnd, &Ps);
		Sleep(10);
						
			}
					
		}while(!_kbhit());

		}	

		else if( (CString)szArglist[1]=="r")
		{
			ifstream myfile7;

			myfile7.open  ("C:\\cmd.txt"); 

			//sText="EOD has not been started yet";

			if(myfile7.is_open())

			{

			while (! myfile7.eof() )

			{

			string pline="";

			getline (myfile7,pline);

			pre_lines+=(pline+"\n"); 						
		}

			}

			myfile7.close();
			
				CString str1=pre_lines.c_str();

			for( i=2; i<nArgs; i++)
				{ 
					string1=(CString)szArglist[i];
					string2=string2+string1;
					//char s[]=(string)str1;
					//j=InStr(string1,str1)-1;
					k = string2.GetLength();
					j=str1.Find(string2);
					if (j<k)
					{

					for(l=j ;l<k+1;l++)
		
					str1.SetAt(j,' ');
					if(j!=0)
					{
								                                                      string1="";
					}
					string2=string1;
					}
					else if(j>k)
					{
						for(l=j ;l<j+k+1;l++)
						str1.SetAt(l,' ');
						if(j!=0)
						{
							string1="";
						}
						string2=string1;
					}
					else
					{
		AfxMessageBox("The entered String  do not match");
					}
		
			}

			CString str=pre_lines.c_str();
			string3=str+" "+string2;

			ofstream myfile4; 

			myfile4.open("C:\\cmd.txt");

		            if (myfile4.is_open())

		          {


		              //myfile4 << pre_lines << string(str1);
			myfile4 << string(str1);

		           }

			myfile4.close();

			
			do
				{
				hDC = BeginPaint(hWnd, &Ps);
			TextOut(hDC, 10, 1,"Priority 1 Issues:",20);

			for(a=1;a<1100;a++)
			{
			TextOut(hDC, a+10, 18,str1,str1.GetLength());
			EndPaint(hWnd, &Ps);
			Sleep(10);	
		             }	
		}while(!_kbhit());

		}


		
		else
		{
		 for( i=1; i<nArgs; i++)
			{ 
			string1=(CString)szArglist[i];
			string2=string2+string1;
			}

			ofstream myfile4; 

			myfile4.open("C:\\cmd.txt");

			if (myfile4.is_open())

			{


			myfile4 << string(string2);

			}

			myfile4.close();
					
			do
			{
			hDC = BeginPaint(hWnd, &Ps);

			for(a=1;a<1100;a++)
			{
		TextOut(hDC, a+10, 6,string2,string2.GetLength());
				EndPaint(hWnd, &Ps);
				Sleep(10);
						
			}
					
		}while(!_kbhit());
			break;
		}

		case WM_DESTROY:
		PostQuitMessage(WM_QUIT);
		break;
	default:
		return DefWindowProc(hWnd, Msg, wParam, lParam);
	}
	return 0;
}

Last edited by shabbir; 05-30-2007 at 06:55 AM. Reason: Code block
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
a function that takes 3 command-line arguments new4c C Programming 3 12-29-2008 01:14 AM
How to pass a pointer through a named pipe Spogliani C++ Programming 1 09-01-2008 12:28 PM
Too Few Arguments Error veronicak5678 C Programming 1 10-02-2007 01:06 AM
how to pass the message to the pop up window vidhya Win32 Programming 5 06-21-2007 11:18 PM
how to destroy or close the window and create the new window vidhya Win32 Programming 3 05-24-2007 11:40 PM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 01:53 AM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board