void BasicMessageBox( TEXTCHAR *title, TEXTCHAR *content ) { PCOMMON msg; TEXTCHAR *start, *end; TEXTCHAR msgtext[256]; int done = 0, okay = 0; int y = 5; msg = CreateFrame( title, 0, 0, 312, 120, 0, frame ); end = start = content; do { while( end[0] && end[0] != '\n' ) end++; if( end[0] ) { MemCpy( msgtext, start, end-start ); msgtext[end-start] = 0; //end[0] = 0; MakeTextControl( msg, 5, y, 302, 16, -1 , msgtext, 0 ); //end[0] = '\n'; end = start = end+1; y += 18; } else MakeTextControl( msg, 5, y, 302, 16, -1 , start, 0 ); } while( end[0] ); //AddExitButton( msg, &done ); AddCommonButtons( msg, NULL, &okay ); DisplayFrame( msg ); CommonLoop( &okay, NULL ); DestroyFrame( &msg ); }
PSI_NAMESPACE PSI_PROC( void, SimpleMessageBox )( PCOMMON parent, CTEXTSTR title, CTEXTSTR content ) { PCOMMON msg; CTEXTSTR start, end; TEXTCHAR msgtext[256]; int okay = 0; int y = 5; uint32_t width, height; uint32_t title_width, greatest_width; #ifdef USE_INTERFACES GetMyInterface(); #endif GetStringSize( content, &width, &height ); title_width = GetStringSize( title, NULL, NULL ); if( title_width > width ) greatest_width = title_width; else greatest_width = width; msg = CreateFrame( title, 0, 0 , greatest_width + 10, height + (COMMON_BUTTON_PAD * 3) + COMMON_BUTTON_HEIGHT , 0, parent ); end = start = content; do { while( end[0] && end[0] != '\n' ) end++; if( end[0] ) { MemCpy( msgtext, (POINTER)start, end-start ); msgtext[end-start] = 0; //end[0] = 0; MakeTextControl( msg, COMMON_BUTTON_PAD, y , greatest_width, height , -1, msgtext, 0 ); //end[0] = '\n'; end = start = end+1; y += height; } else MakeTextControl( msg, COMMON_BUTTON_PAD, y , greatest_width, height , -1, start, 0 ); } while( end[0] ); //AddExitButton( msg, &done ); AddCommonButtons( msg, NULL, &okay ); lprintf( WIDE("show message box") ); DisplayFrame( msg ); CommonWait( msg ); DestroyFrame( &msg ); }
int SimpleUserQueryEx( TEXTSTR result, int reslen, CTEXTSTR question, PSI_CONTROL pAbove, void (CPROC*query_success_callback)(uintptr_t, LOGICAL), uintptr_t query_user_data ) { PSI_CONTROL pf, pc; struct user_query_info *query_state = New( struct user_query_info ); int32_t mouse_x, mouse_y; //int Done = FALSE, Okay = FALSE; pf = CreateFrame( NULL, 0, 0, 280, 65, 0, pAbove ); SetCommonUserData( pf, (uintptr_t)query_state ); query_state->pf = pf; query_state->Done = FALSE; query_state->Okay = FALSE; query_state->result = result; query_state->reslen = reslen; pc = MakeTextControl( pf, 5, 2, 320, 18, TXT_STATIC, question, TEXT_NORMAL ); query_state->edit = MakeEditControl( pf, 5, 23, 270, 14, TXT_STATIC, NULL, 0 ); AddCommonButtons( pf, &query_state->Done, &query_state->Okay ); SetButtonPushMethod( GetControl( pf, IDOK ), OkayClicked, (uintptr_t)query_state ); SetButtonPushMethod( GetControl( pf, IDCANCEL ), CancelClicked, (uintptr_t)query_state ); GetMousePosition( &mouse_x, &mouse_y ); MoveFrame( pf, mouse_x - 140, mouse_y - 30 ); //lprintf( WIDE("Show query....") ); DisplayFrame( pf ); SetCommonFocus( query_state->edit ); query_state->query_success = query_success_callback; if( !query_success_callback ) { int okay; CommonWait( pf ); if( query_state->Okay ) { GetControlText( query_state->edit, result, reslen ); } DestroyFrame( &pf ); okay = query_state->Okay; Release( query_state ); return okay; } else { query_state->query_success = query_success_callback; query_state->query_user_data = query_user_data; return 0; } }