Exemple #1
0
/* TinTree "tins" a tree into an external structure. The complete structure
 * is allocated by one call to IfcAllocateMemory. The returned value shall
 * be used as an instore macro for RexxStart.
 * *length is set to the allocated size of the memory block on return.
 * ExpandedTinnedTree can expand the returned value and IsValidTin checks it.
 */
external_parser_type *TinTree(const tsd_t *TSD,
                              const internal_parser_type *ipt,
                              unsigned long *length)
{
   external_parser_type *retval;
   unsigned long srclines, nodecount, len;

   *length = ComputeExternalSize(ipt, &srclines, &nodecount);

   retval = (external_parser_type *)IfcAllocateMemory(*length);
   if (retval == NULL)
      return(NULL);
   memset(retval, 0, sizeof(external_parser_type));

   /* Build the envelope */
   len = sizeof(MagicHeader); /* includes a terminating 0 */
   if (len > sizeof(retval->Magic))
      len = sizeof(retval->Magic);
   memcpy(retval->Magic, MagicHeader, len);
   len = sizeof(PARSE_VERSION_STRING);
   if (len > sizeof(retval->ReginaVersion))
      len = sizeof(retval->ReginaVersion);
   memcpy(retval->ReginaVersion, PARSE_VERSION_STRING, len);

   retval->arch_detector.s.one = 1;
   retval->arch_detector.s.two = 2;
   retval->arch_detector.s.ptr3 = (void *)3;
   retval->arch_detector.s.ptr4 = (void *)4;
   retval->OverallSize = (unsigned long) *length;
   retval->NumberOfSourceLines = srclines;
   retval->version = INSTORE_VERSION;
   retval->NumberOfTreeElements = nodecount;

   retval->source = sizeof(external_parser_type);
   len = FillStrings((char *) retval,
                     sizeof(external_parser_type),
                     ipt->srclines);

   retval->tree = len;
   retval->TreeStart = ipt->root->nodeindex;
   len = FillTree((treenode *) ((char *) retval + len),
                  (char *) retval,
                  len + nodecount*sizeof(treenode),
                  ipt->nodes);

   memcpy((char *) retval + len, retval->Magic, sizeof(retval->Magic));

   assert((unsigned long) len + sizeof(retval->Magic) == *length);

   /* DEBUGGING: return NULL if you don't want tinned trees */
   TSD = TSD; /* keep compiler happy */
   return(retval);
}
Exemple #2
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	//RECT rect;
	HDC hdc;

	HDC hdcControl;

	string result = "";

	const int limitEdit = 100;

	static HBRUSH hBrush = CreateSolidBrush(RGB(230, 230, 230));

	DWORD CtrlID;

	//static int flag = -1;

	switch (message){

	case WM_CTLCOLORSTATIC:
	{
		if (staticLabel == (HWND)lParam)

			//OR if the handle is unavailable to you, get ctrl ID

		CtrlID = GetDlgCtrlID((HWND)lParam); //Window Control ID
		if (CtrlID == ID_STATIC_LBL) //If desired control
			{
				HDC hdcStatic = (HDC)wParam;
				SetTextColor(hdcStatic, RGB(0, 0, 0));
				SetBkColor(hdcStatic, RGB(230, 230, 230));
				return (INT_PTR)hBrush;
			}
	}

	
	case WM_CREATE:

		staticLabel = CreateWindowEx(NULL, controlNames[STATIC], "Surname",
			WS_CHILD | WS_VISIBLE | SS_SIMPLE,
			LIST_X, LIST_Y, BTN_H_SIZE, BTN_V_SIZE, hWnd, (HMENU)ID_STATIC_LBL, hinst, NULL);
		


		editSurname = CreateWindowEx(WS_EX_CLIENTEDGE, controlNames[EDIT], "",
			WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL,
			LIST_X, LIST_Y + BTN_V_SIZE, EDIT_BOX_H_SIZE, BTN_V_SIZE, hWnd, (HMENU)ID_EDIT_SURNAME, hinst, NULL);

		Edit_LimitText(editSurname, limitEdit);

		comboboxSpecialty = CreateWindowEx(WS_EX_CLIENTEDGE, controlNames[COMBOBOX], "",
			WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,
			LIST_X, LIST_Y + BTN_V_SIZE + EDIT_BOX_V_SIZE, BTN_H_SIZE, COMBO_V_SIZE, hWnd, 
			(HMENU)ID_COMBO_BOX_SPEC, hinst, NULL);

		FillStrings(specialty, hWnd, comboboxSpecialty);

		buttonRecord = CreateWindowEx(WS_EX_CLIENTEDGE, controlNames[BUTTON], "Record",
			WS_CHILD | WS_VISIBLE,
			LIST_X * 2 + BTN_H_SIZE, LIST_Y + BTN_V_SIZE + EDIT_BOX_V_SIZE, BTN_H_SIZE, BTN_V_SIZE, hWnd, 
			(HMENU)ID_BTN_REC, hinst, NULL);

		listConcat = CreateWindowEx(WS_EX_CLIENTEDGE, controlNames[LISTBOX], "",
			WS_CHILD | WS_VISIBLE,
			LIST_X * 2 + EDIT_BOX_H_SIZE, LIST_Y + BTN_V_SIZE, LIST_H_SIZE, LIST_V_SIZE, hWnd,
			(HMENU)ID_LIST_CONCAT, hinst, NULL);

		break;

	case WM_COMMAND:
	{
		switch (LOWORD(wParam)){

		case ID_BTN_REC:
			if (HIWORD(wParam) == BN_CLICKED)
			{
				try{

					result = GetInfo(comboboxSpecialty, editSurname, hWnd);

				}
				catch (char* s){

				MessageBox(hWnd, s, s, NULL);

				break;
				}
				
				SendInfo(listConcat, result);
				
				break;

			}//switch (LOWORD(wParam)){

		}// case WM_COMMAND:

		break;

	case WM_PAINT:

		hdc = BeginPaint(hWnd, &ps);

		EndPaint(hWnd, &ps);

		break;

	case WM_DESTROY:

		PostQuitMessage(0);

		break;

	default:

		return DefWindowProc(hWnd, message, wParam, lParam);

		break;

	}//switch (message)

	return 0;

	}// LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

}