示例#1
0
PCLIENT ConnectToRelay( PCLIENT *pc )
{
    TEXTCHAR address[128];
    if( InProgress )
    {
        BasicMessageBox( WIDE("Request in progress"), WIDE("Please wait a moment for\n")
                         WIDE("the current operation to finish") );
        return NULL;
    }
    InProgress = TRUE;
    NetworkWait( NULL, 5, 16 );
    GetControlText( GetControl( frame, EDT_SERVER ), address, sizeof( address ) );

    *pc = OpenTCPClientEx( address, 3001, ReadComplete, ConnectionClose, NULL );
    if( !(*pc) )
    {
        BasicMessageBox( WIDE("Bad Address?"),
                         WIDE("Check the address - could not connect") );
        return NULL;
    }
    ppc_current = pc;
    {
        FILE *file = sack_fopen( 0, WIDE("LastConnection.data"), WIDE("wb") );
        if( file )
        {
            fprintf( file, WIDE("%s"), address );
            fclose( file );
        }
    }
    return *pc;
}
示例#2
0
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;
	}

}
示例#3
0
static int OnDrawCommon( BANNER_NAME )( PCONTROL pc )
{
	static TEXTCHAR caption[4096];
	PBANNER *ppBanner = (PBANNER*)GetCommonUserData( pc );
	if( !ppBanner )
		return 0;
	else
	{
		PBANNER banner = (*ppBanner);
		if( banner )
		{
			Image image = GetControlSurface( pc );
			if( banner->old_width != image->width || banner->old_height != image->height )
			{
				banner_local.w
					= banner->old_width
					= image->width;
            banner_local.h
					= banner->old_height
					= image->height;
				RerenderFont( banner_local.font
								, image->width / 18, banner_local.h/10
								, NULL, NULL );
				// clear bounds-set so a full background is drawn.
				banner->bit_flags.bounds_set = 0;
			}
			banner->bit_flags.drawing = 1;
			GetControlText( pc, caption, sizeof( caption )/sizeof(TEXTCHAR) );
#ifdef DEBUG_BANNER_DRAW_UPDATE
			lprintf( WIDE( "--------- BANNER DRAW %s -------------" ), caption );
#endif
			DrawBannerCaption( pc, banner, image
								  , caption
								  , banner->textcolor
								  , (banner->flags & ( BANNER_OPTION_YESNO|BANNER_OPTION_OKAYCANCEL ))
									? ( (image->height * 1 ) / 3 )
									: ((image->height)/2)
								  , 0
								  , banner->flags & BANNER_OPTION_LEFT_JUSTIFY
								  , banner->flags & BANNER_EXPLORER
								  );
			banner->bit_flags.drawing = 0;
		}
	}
	return TRUE;
}
示例#4
0
static void CPROC OkayClicked( uintptr_t psv, PSI_CONTROL pc )
{
	struct user_query_info *query_state = (struct user_query_info *)psv;
	query_state->Okay = 1;
	query_state->Done = 1;
	GetControlText( query_state->edit, query_state->result, query_state->reslen );
	if( query_state->query_success )
	{
		query_state->query_success( query_state->query_user_data, TRUE );
		{
			PSI_CONTROL pf = GetFrame( pc );
			DestroyFrame( &pf );
		}
		Release( query_state );
	}
	//Release( query_state->result );
}
示例#5
0
文件: seek_slider.c 项目: d3x0r/SACK
static uintptr_t OnConfigureControl( CONTROL_NAME )( uintptr_t psv, PSI_CONTROL parent_frame )
{
	PSLIDER_INFO info = (PSLIDER_INFO)psv;
	{
		PSI_CONTROL frame = NULL; 
		int okay = 0;
		int done = 0;
		if( !frame )
		{
			frame = LoadXMLFrame( "seek_slider_properties.frame" );
			if( frame )
			{
				 TEXTCHAR buffer[256];

				SetCommonButtonControls( frame );
				
				SetCheckState( GetControl( frame, CHECKBOX_HORIZONTAL ), info->flags.bHorizontal );
				SetCheckState( GetControl( frame, CHECKBOX_DRAGGING ), info->flags.bDragging );
				SetControlText( GetControl( frame, EDIT_BACKGROUND_IMAGE ), info->image_name );

					 snprintf(buffer, sizeof(buffer), "%d", info->min);
				SetControlText( GetControl( frame, EDIT_MIN ), buffer );

					 snprintf(buffer, sizeof(buffer), "%d", info->max);
				SetControlText( GetControl( frame, EDIT_MAX ), buffer );
				
					 snprintf(buffer, sizeof(buffer), "%d", info->current);
				SetControlText( GetControl( frame, EDIT_CURRENT ), buffer );
				
				SetCommonButtons( frame, &done, &okay );
				DisplayFrameOver( frame, parent_frame );
				CommonWait( frame );

				if( okay )
				{
					GetCommonButtonControls( frame );
					info->font = InterShell_GetCurrentButtonFont();
					if( info->font )
						SetCommonFont( info->control, (*info->font ) );
					info->color = GetColorFromWell( GetControl( frame, CLR_TEXT_COLOR ) );
					info->backcolor = GetColorFromWell( GetControl( frame, CLR_BACKGROUND ) );
					{
						GetControlText( GetControl( frame, EDIT_BACKGROUND_IMAGE ), buffer, sizeof( buffer ) );
						if( info->image_name )
							Release( info->image_name );
						info->image_name = StrDup( buffer );
					}

//					SetSliderColor( info->control, info->color );
//					SetSliderkBackColor( info->control, info->backcolor );

					info->flags.bHorizontal = GetCheckState( GetControl( frame, CHECKBOX_HORIZONTAL ) );
					info->flags.bDragging = GetCheckState( GetControl( frame, CHECKBOX_DRAGGING ) );

					GetControlText( GetControl( frame, EDIT_MIN), buffer, sizeof( buffer ) );
					info->min = atoi(buffer);
					GetControlText( GetControl( frame, EDIT_MAX), buffer, sizeof( buffer ) );
					info->max = atoi(buffer);
					GetControlText( GetControl( frame, EDIT_CURRENT), buffer, sizeof( buffer ) );
					info->current = atoi(buffer);

				}
				DestroyFrame( &frame );
			}
		}
	}
	return psv;
}