Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SETTEXT OF DIALOG??????

Status
Not open for further replies.

computerwhiz

Programmer
May 1, 2002
28
US
Why is it that I can load whatever size file I want into the edit dialog when I am on "Windows 2000 Professional" but as soon as I run this program on windows 98 I can load the file text into memory but I cannot set the edit dialog text if the amount of text is over 64K? I am truly confused. am I going about this the wrong way?


Code:
#include <windows.h>
#include <commctrl.h>

#include &quot;Main.h&quot;

static char g_szClassName[] = &quot;MyWindowClass&quot;;
static HINSTANCE g_hInst = NULL;
static HWND	g_hStatusBar;
static BOOL ReadyToParse = FALSE;
static BOOL Neg=FALSE;
static BOOL EnableFlag=FALSE;
static LPSTR pszText;
static LPSTR Quote_A=&quot;\&quot;&quot;;
static LPSTR Quote_B=&quot;\&quot;,\&quot;&quot;;
static LPSTR Quote_C=&quot;\&quot;,&quot;;
static LPSTR Quote_D=&quot;,&quot;;
static LPSTR Return=&quot;\r\n&quot;;
static LPSTR Header=&quot;\&quot;Number\&quot;,\&quot;Date\&quot;,\&quot;Remark\&quot;,\&quot;Gross\&quot;,\&quot;Deductions\&quot;,\&quot;Amount Paid\&quot;&quot;;
static int txtpos=0, count=0;


#define ID_STATUSBAR       4997
#define IDC_MAIN_TEXT   1001

void Insert(int Pos, LPSTR String)
{
	if (Pos<0 || Pos>strlen(pszText) || String == 0X00)
	{
		return;
	}
	LPSTR NewText = (LPSTR)GlobalAlloc(GPTR, strlen(String)+strlen(pszText) + 2);
	if (Pos > 0)			
	{
		memcpy(NewText, pszText, Pos);
	}
	memcpy(NewText+Pos, String, strlen(String));
	if (strlen(pszText)-Pos > 0)
	{		
		memcpy(NewText+Pos+strlen(String), pszText+Pos, strlen(pszText)-Pos);
	}
	GlobalFree(pszText);
	pszText = (LPSTR)GlobalAlloc(GPTR, strlen(NewText) + 2);
	strcpy(pszText, NewText);
	pszText[strlen(NewText)+1] = 0x00;
	GlobalFree(NewText);
}

void Delete(int Pos, int Count)
{
	int Len = strlen(pszText);
	LPSTR NewText = (LPSTR)GlobalAlloc(GPTR, Len+2);
	memmove(pszText+Pos, pszText+Pos+Count, Len-Pos-Count);
	pszText[Len-Count+1] = 0x00;
	strcpy(NewText, pszText);
	GlobalFree(pszText);
	pszText = (LPSTR)GlobalAlloc(GPTR, strlen(NewText) + 2);
	strcpy(pszText, NewText);
	pszText[strlen(NewText)+1] = 0x00;
	GlobalFree(NewText);
}

void ProcessHeader(int ChkType)
{
	if(ChkType == 1)
	{
		Delete(0, 191), Insert(0, Quote_A), Insert(10, Quote_A);
		Delete(11, 74), Insert(11, Return), Insert(13, Quote_A);
		Insert(22, Quote_A), Insert(25, Quote_A), Insert(84, Quote_A);
		Insert(85, Return), Delete(87, 205), Insert(87, Header);
	}
	else if(ChkType == 2)
	{
		Delete(0, 159), Insert(0, Quote_A), Insert(36, Quote_A);
		Insert(37, Return), Delete(39, 13), Insert(39, Quote_A);
		Insert(49, Quote_A), Delete(52,79), Insert(52, Quote_A);
		Insert(61, Quote_A), Delete(62, 100), Insert(64, Header);
	}
}

void ProcessBody(int BdyType, int NumbPgs, LPSTR Pages)
{
	int adj=0, adj2=0, adj3=0, Loop=0, NextBit=0, brk=0;
	LPSTR TempStr = (LPSTR)GlobalAlloc(GPTR, 12);
	LPSTR pszStatusBarTxt = (LPSTR)GlobalAlloc(GPTR, 70);
	LPSTR pszStatusBarTxt2 = (LPSTR)GlobalAlloc(GPTR, 30);
	strcpy(pszStatusBarTxt2, &quot;Pages to process: &quot;);
	strcpy(pszStatusBarTxt2+18, Pages);
	SendMessage(g_hStatusBar, SB_SETTEXT, 1, (LPARAM)pszStatusBarTxt2);
	
	if(BdyType == 1)
	{
		txtpos=148;
		for(Loop=1; Loop <= NumbPgs; Loop++)
		{
			count = 1;
			memset(pszStatusBarTxt, 0x00, sizeof(pszStatusBarTxt));
   		strcpy(pszStatusBarTxt, &quot;parsing.&quot;);
			SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)pszStatusBarTxt);
			while(count <= 50)
			{
				adj = 0, adj2 = 0;
				strcat(pszStatusBarTxt, &quot;.&quot;);
				SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)pszStatusBarTxt);
				if(brk == 1) brk++;
				strncpy(TempStr, pszText+txtpos+36, 11);
				TempStr[11] = 0x00;

				Insert(txtpos, Quote_A);
				Delete(txtpos+11, 1), Insert(txtpos+11, Quote_B);//number
				Delete(txtpos+19,1), Insert(txtpos+19, Quote_B);//date
				Insert(txtpos+48, Quote_C);//info
				Delete(txtpos+52, 1);//remove comma in gross
				Delete(txtpos+55, 1);//remove comma in gross
				Insert(txtpos+62, Quote_D);//gross
				Delete(txtpos+64, 1);//remove comma in disc
				Delete(txtpos+67, 1);//remove comma in disc
				Insert(txtpos+74, Quote_D);//discount
				Delete(txtpos+77, 1);//remove comma in amount
				Delete(txtpos+80, 1);//remove comma in amount
         
				if(pszText[txtpos+86] == 0x02D) adj2++;
         
				if(pszText[txtpos+61] == 0x02D)
				{
					Delete(txtpos+61, 1), Insert(txtpos+50, &quot;-&quot;);
				}
				else
				{
					Delete(txtpos+61, 1), adj--;
				}
         
				if(pszText[txtpos+70+adj] != 0x02E & pszText[txtpos+70+adj] != 0x02D)
				{
					Delete(txtpos+72+adj, 1);//add a zero to blank disc
					Insert(txtpos+72+adj, &quot;0&quot;);
				}

				if(pszText[txtpos+73+adj] == 0x02D)
				{
					Delete(txtpos+73+adj, 1), Insert(txtpos+63+adj, &quot;-&quot;);
				}
				else
				{
					Delete(txtpos+73+adj, 1), adj--;
				}

				if(pszText[txtpos+86+adj] == 0x02D)
				{
					Delete(txtpos+86+adj, 1), Insert(txtpos+75+adj, &quot;-&quot;);
				}
				NextBit = 0;
				while(pszText[txtpos+48+NextBit] != 0x00D)
				{
					while(isspace(pszText[txtpos+48+NextBit]))
					{
						Delete(txtpos+48+NextBit, 1);
						adj--;
					}
					NextBit++;
				}
				if(strstr(TempStr, &quot;       ----&quot;))
				{
					adj3 = txtpos;
					brk++;
				}
				count++;
				txtpos += 88 + adj + adj2;
				if(brk == 2) break;
			}
			if(brk != 2 & Loop < NumbPgs)
			{
				Delete(txtpos, 450);
			}
			else if(brk == 2)
			{
				Delete(adj3, 86);
				txtpos -= 87;
			}
		}
		Delete(txtpos, strlen(pszText)-txtpos);//remove remaining of file
	}

	if(BdyType == 2)
	{
		txtpos=125, count=1;
		strcpy(pszStatusBarTxt, &quot;parsing.&quot;);
		while(count <=27)
		{
			adj = 0, adj2 = 0;
			SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)pszStatusBarTxt);
			strcat(pszStatusBarTxt, &quot;.&quot;);
			if(brk == 1) brk++;
			strncpy(TempStr, pszText+txtpos+58, 11);
			TempStr[11] = 0x00;
			Delete(txtpos, 9), Insert(txtpos, Quote_A);
			Delete(txtpos+11, 1), Insert(txtpos+11, Quote_B);//number
			Delete(txtpos+20,1), Insert(txtpos+20, Quote_B);//date
			Insert(txtpos+54, Quote_C);//info
			Delete(txtpos+60, 1);//remove comma in gross
			Insert(txtpos+67, Quote_D);
			Delete(txtpos+72, 1);//remove comma in disc
			Insert(txtpos+79, Quote_D);
			Delete(txtpos+84, 1);//remove comma in amount
			if(pszText[txtpos+90] == 0x02D) adj2++;
			if(pszText[txtpos+66] == 0x02D)
			{
				Delete(txtpos+66, 1), Insert(txtpos+56, &quot;-&quot;);
			}
			else
			{
				Delete(txtpos+66, 1), adj--;
			}
			if(pszText[txtpos+75+adj] != 0x02E & pszText[txtpos+75+adj] != 0x02D)
			{
				Delete(txtpos+77+adj, 1);//add a zero to blank disc
				Insert(txtpos+77+adj, &quot;0&quot;);
			}
			if(pszText[txtpos+78+adj] == 0x02D)
			{
				Delete(txtpos+78+adj, 1), Insert(txtpos+68+adj, &quot;-&quot;);
			}
			else
			{
				Delete(txtpos+78+adj, 1), adj--;
			}
			if(pszText[txtpos+90+adj] == 0x02D)
			{
				Delete(txtpos+90+adj, 1), Insert(txtpos+80+adj, &quot;-&quot;);
			}
			NextBit = 0;
			while(pszText[txtpos+56+NextBit] != 0x00D)
			{
				while(isspace(pszText[txtpos+56+NextBit]))
				{
					Delete(txtpos+56+NextBit, 1);
					adj--;
				}
				NextBit++;
			}
			if(strstr(TempStr, &quot;-----------&quot;))
			{
				adj3 = txtpos;
				brk++;
			}
			count++;
			txtpos += 92 + adj + adj2;
			if(brk == 2) break;
		}
		if(brk == 2)
		{
			Delete(adj3, 90);
			txtpos -= 91;
		}
		Delete(txtpos, strlen(pszText)-txtpos);//remove remaining of file
	}
	GlobalFree(pszStatusBarTxt);
	GlobalFree(pszStatusBarTxt2);
	GlobalFree(TempStr);
	SendMessage(g_hStatusBar, SB_SETTEXT, 1, (LPARAM)&quot;&quot;);
}

void ProcessFile(HWND hEdit)
{
	if (ReadyToParse)
	{
		DWORD dwTextLngth;
		char Pages[5];
		int PagesInt = 0;
		dwTextLngth = GetWindowTextLength(GetDlgItem(hEdit, IDC_MAIN_TEXT));
		if(dwTextLngth > 400)
		{
			pszText = (LPSTR)GlobalAlloc(GPTR, dwTextLngth + 1);
			if(pszText != NULL)
			{
				if(GetWindowText(GetDlgItem(hEdit, IDC_MAIN_TEXT), pszText, dwTextLngth + 1))
				{
					if(strstr(pszText, &quot;Payment Attachment&quot;))
					{
						SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)&quot;Parsing.&quot;);
						strncpy(Pages, pszText+356, 4);
						Pages[4] = 0x00;
						PagesInt = atoi(Pages);
						ProcessHeader(1);
						ProcessBody(1, PagesInt, Pages);
						SetWindowText(GetDlgItem(hEdit, IDC_MAIN_TEXT), pszText);
						SendMessage(g_hStatusBar, SB_SETTEXT, 0,
      				(LPARAM)&quot;Parsing is finished, please save your work.&quot;);
					}
					else if(strstr(pszText, &quot;Payee:&quot;))
					{
						SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)&quot;Parsing.&quot;);
						ProcessHeader(2);
						ProcessBody(2, 0, NULL);
						SetWindowText(GetDlgItem(hEdit, IDC_MAIN_TEXT), pszText);
						SendMessage(g_hStatusBar, SB_SETTEXT, 0,
      				(LPARAM)&quot;Parsing is finished, please save your work.&quot;);
					}
				}
			}
			GlobalFree(pszText);
		}
		else
		{
			MessageBox(hEdit, &quot;No text to parse.&quot;, &quot;FAILURE&quot;,
				MB_OK | MB_ICONEXCLAMATION);
		}
		ReadyToParse = FALSE;
		HMENU hMenu;
		hMenu = GetMenu(hEdit);
		EnableFlag = FALSE;
		EnableMenuItem(hMenu, 1, MF_BYPOSITION | (EnableFlag ? MF_ENABLED : MF_GRAYED));
		DrawMenuBar(hEdit);
	}
	else
	{
		HMENU hMenu;
		hMenu = GetMenu(hEdit);
		EnableFlag = FALSE;
		EnableMenuItem(hMenu, 1, MF_BYPOSITION | (EnableFlag ? MF_ENABLED : MF_GRAYED));
		DrawMenuBar(hEdit);
	} 
}

void SetWndTitle(HWND hMain, LPSTR pszTitle)
{
	char NewWindowTitle[50] = &quot;Check Parser -- &quot;;
	LPSTR Temp = strrchr(pszTitle, 0x05C)+1;
	memcpy(NewWindowTitle+16, Temp, strlen(Temp)+1);
	SetWindowText(hMain, NewWindowTitle);
}

BOOL LoadFile(HWND hMain, HWND hEdit, LPSTR pszFileName)
{
	HANDLE hFile;
	BOOL bSuccess = FALSE;
	hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
	OPEN_EXISTING, 0, 0);
	if(hFile != INVALID_HANDLE_VALUE)
	{
		DWORD dwFileSize;
		dwFileSize = GetFileSize(hFile, NULL);
		if(dwFileSize != 0xFFFFFFFF)
		{
			LPSTR pszFileText;
			pszFileText = (LPSTR)GlobalAlloc(GPTR, dwFileSize + 1);
			if(pszFileText != NULL)
			{
				DWORD dwRead;
				if(ReadFile(hFile, pszFileText, dwFileSize, &dwRead, NULL))
				{
					pszFileText[dwFileSize] = 0;
					if(SetWindowText(hEdit, pszFileText))
					{
						DWORD dwTextLength;
						dwTextLength = GetWindowTextLength(hEdit);
						if(dwTextLength > 1)
						{
							bSuccess = TRUE;
							ReadyToParse = TRUE;
							SetWndTitle(hMain, pszFileName);
							SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)&quot;Ready to parse file.&quot;);
						}
					}
				}
				GlobalFree(pszFileText);
			}
		}
		CloseHandle(hFile);
	}
	return bSuccess;
}

BOOL SaveFile(HWND hEdit, LPSTR pszFileName)
{
	HANDLE hFile;
	BOOL bSuccess = FALSE;

	hFile = CreateFile(pszFileName, GENERIC_WRITE, 0, 0,
	CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
	if(hFile != INVALID_HANDLE_VALUE)
	{
		DWORD dwTextLength;
		dwTextLength = GetWindowTextLength(hEdit);
		if(dwTextLength > 0)
		{
			LPSTR pszText;
			pszText = (LPSTR)GlobalAlloc(GPTR, dwTextLength + 1);
			if(pszText != NULL)
			{
				if(GetWindowText(hEdit, pszText, dwTextLength + 1))
				{
					DWORD dwWritten;
					if(WriteFile(hFile, pszText, dwTextLength, &dwWritten, NULL)) bSuccess = TRUE;
					SendMessage(g_hStatusBar, SB_SETTEXT, 0,
					(LPARAM)&quot;File was saved successfully.&quot;);
				}
				GlobalFree(pszText);
			}
		}
		CloseHandle(hFile);
	}
	return bSuccess;
}

BOOL DoFileOpenSave(HWND hwnd, BOOL bSave)
{
	OPENFILENAME ofn;
	char szFileName[MAX_PATH];

	ZeroMemory(&ofn, sizeof(ofn));
	szFileName[0] = 0;

	ofn.lStructSize = sizeof(OPENFILENAME);//sizeof(ofn)  msdn says win98/NT4 should use this.
	ofn.hwndOwner = hwnd;
	ofn.lpstrFile = szFileName;
	ofn.nMaxFile = MAX_PATH;
	ofn.lpstrDefExt = &quot;htm&quot;;

	if(bSave)
	{
		ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY |
		OFN_OVERWRITEPROMPT;
		ofn.lpstrFilter = &quot;CSV Files (*.csv)\0*.csv\0\0&quot;;
		if(GetSaveFileName(&ofn))
		{
			if(!SaveFile(GetDlgItem(hwnd, IDC_MAIN_TEXT), szFileName))
			{
				MessageBox(hwnd, &quot;Save file failed.&quot;, &quot;Error&quot;,
				MB_OK | MB_ICONEXCLAMATION);
				return FALSE;
			}
		}
	}
	else
	{
		ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
		ofn.lpstrFilter = &quot;Html Files (*.htm)\0*.htm\0All Files (*.*)\0*.*\0\0&quot;;
		if(GetOpenFileName(&ofn))
		{
			if(!LoadFile(hwnd, GetDlgItem(hwnd, IDC_MAIN_TEXT), szFileName))
			{
				MessageBox(hwnd, &quot;Load of file failed.&quot;, &quot;Error&quot;,
				MB_OK | MB_ICONEXCLAMATION);
				return FALSE;
			}
		}
	}
	return TRUE;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
	switch(Message)
	{
		case WM_CREATE:
		{
			int iStatusWidths[] = {250, -1};
			CreateWindow(&quot;EDIT&quot;, &quot;&quot;,
			WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE |
			ES_WANTRETURN,
			CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
			hwnd, (HMENU)IDC_MAIN_TEXT, g_hInst, NULL);

			g_hStatusBar = CreateWindowEx(0, STATUSCLASSNAME, NULL,
			WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0,
			hwnd, (HMENU)ID_STATUSBAR, g_hInst, NULL);

			SendMessage(g_hStatusBar, SB_SETPARTS, 2, (LPARAM)iStatusWidths);
			SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)&quot;Ready to open a file.&quot;);
			SendDlgItemMessage(hwnd, IDC_MAIN_TEXT, WM_SETFONT,
			(WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(TRUE, 0));
			break;
		}
		case WM_SIZE:
		{
			RECT rectClient, rectStatus;
			UINT uToolHeight, uStatusHeight, uClientAlreaHeight;

			SendMessage(g_hStatusBar, WM_SIZE, 0, 0);

			GetClientRect(hwnd, &rectClient);
			GetWindowRect(g_hStatusBar, &rectStatus);

			uStatusHeight = rectStatus.bottom - rectStatus.top;
			uClientAlreaHeight = rectClient.bottom;

			if(wParam != SIZE_MINIMIZED)
			MoveWindow(GetDlgItem(hwnd, IDC_MAIN_TEXT), 0, 0, rectClient.right,
			uClientAlreaHeight-uStatusHeight, TRUE);
			break;
		}
		case WM_SETFOCUS:
			SetFocus(GetDlgItem(hwnd, IDC_MAIN_TEXT));
			break;
		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case CM_FILE_OPEN:
					if(DoFileOpenSave(hwnd, FALSE))
					{
						HMENU hMenu, hFileMenu;
						hMenu = GetMenu(hwnd);
         					EnableFlag = TRUE;
         					EnableMenuItem(hMenu, 1, MF_BYPOSITION | (EnableFlag ? MF_ENABLED : MF_GRAYED));
         					hFileMenu = GetSubMenu(hMenu, 0);
         					EnableMenuItem(hFileMenu, CM_FILE_SAVEAS, MF_BYCOMMAND | (EnableFlag ? MF_ENABLED : MF_GRAYED));
         					DrawMenuBar(hwnd);
       					}
					break;
				case CM_FILE_SAVEAS:
					if(DoFileOpenSave(hwnd, TRUE))
					{
						HMENU hMenu, hFileMenu;
						hMenu = GetMenu(hwnd);
				         	EnableFlag = FALSE;
				         	EnableMenuItem(hMenu, 1, MF_BYPOSITION | (EnableFlag ? MF_ENABLED : MF_GRAYED));
				         	hFileMenu = GetSubMenu(hMenu, 0);
				         	EnableMenuItem(hFileMenu, CM_FILE_SAVEAS, MF_BYCOMMAND | (EnableFlag ? MF_ENABLED : MF_GRAYED));
			        	 	DrawMenuBar(hwnd);
			         	}
			         	break;
				case CM_FILE_EXIT:
					PostMessage(hwnd, WM_CLOSE, 0, 0);
					break;
				case CM_PARSE_FILE:
					ProcessFile(hwnd);
					break;
				case CM_ABOUT:
					MessageBox (NULL, 
					&quot;MBS TEXTBOOK EXCHANGE, INC.\n&quot;
					&quot;Copyright 2003\n\n&quot;
					&quot;Check parser was designed for the easy\n&quot;
					&quot;conversion of MBS Accounts Payable check\n&quot;
					&quot;remittances into .CSV files.  Making it easier to\n&quot;
					&quot;load the data into a spreadsheet.\n\nDesigned by Dave Dartt&quot; ,
					&quot;About...&quot;, 0);
			}
			break;
		case WM_CLOSE:
			DestroyWindow(hwnd);
			break;
		case WM_DESTROY:
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hwnd, Message, wParam, lParam);
	}
	return 0;
}


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
   LPSTR lpCmdLine, int nCmdShow)
{
	WNDCLASSEX WndClass;
	HWND hwnd;
	MSG Msg;

	g_hInst = hInstance;

	WndClass.cbSize        = sizeof(WNDCLASSEX);
	WndClass.style         = 0;
	WndClass.lpfnWndProc   = WndProc;
	WndClass.cbClsExtra    = 0;
	WndClass.cbWndExtra    = 0;
	WndClass.hInstance     = g_hInst;
	WndClass.hIcon         = LoadImage(NULL, &quot;chkparser.ico&quot;, IMAGE_ICON, 32, 32, LR_LOADFROMFILE);
	WndClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
	WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	WndClass.lpszMenuName  = &quot;MAINMENU&quot;;
	WndClass.lpszClassName = g_szClassName;
	WndClass.hIconSm       = LoadImage(NULL, &quot;chkparser.ico&quot;, IMAGE_ICON, 16, 16, LR_LOADFROMFILE);


	if(!RegisterClassEx(&WndClass))
	{
		MessageBox(0, &quot;Window Registration Failed!&quot;, &quot;Error!&quot;,
			MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
		return 0;
	}

	hwnd = CreateWindowEx(
	WS_EX_CLIENTEDGE,
	g_szClassName, &quot;Check Parser&quot;,
	WS_OVERLAPPEDWINDOW,
	CW_USEDEFAULT, CW_USEDEFAULT, 550, 400,
	NULL, NULL, g_hInst, NULL);

	if(hwnd == NULL)
	{
		MessageBox(0, &quot;Window Creation Failed!&quot;, &quot;Error!&quot;,
			MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
		return 0;
	}

	ShowWindow(hwnd, nCmdShow);
	UpdateWindow(hwnd);

	while(GetMessage(&Msg, NULL, 0, 0))
	{
		TranslateMessage(&Msg);
		DispatchMessage(&Msg);
	}
	return Msg.wParam;
}
 
MSDN:
In general, Windows edit controls were designed as vehicles into which the user can enter and edit small amounts of text. They cannot be used as large-scale text editors.
...
Initially, the user can enter a maximum of 30,000 bytes into a multiline edit control. If the user attempts to enter more text, the edit control beeps and does not accept the characters. An application can set this limit to any value between 1 and 65,535 (0xFFFF) characters by sending the edit control an EM_LIMITTEXT message.
...
An application can specify a global text buffer for an edit control. By using a global buffer, an edit control can store almost 64K of data. The actual size limit of an edit control depends on the number of lines stored in the edit control.
...
MSDN Q74225. Last Reviewed: June 10, 1999.


Windows 98 has older version of Edit Controls (at least Rich Edit Ctrl v.2.0, W2k - v.3.0). You may detect Windows version in your application, but it's the other story...
 
is there a large scale text editor dialog box that can be used? Or should I just rethink this whole procedure and use textout to display the file text? Would the dialog be able to handle the amount of data using textout?
 
don't put long codes in the forum, because they will be deleted.

Ion Filipski
1c.bmp
 
The best large scale Windows editor is MS Word. It is automation server, you can invoke and control it from C++ app.
There are third parties large scale text edit controls. I don't remember its names (commercial soft)...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top