Showing posts with label dialog. Show all posts
Showing posts with label dialog. Show all posts
2016/11/03
Using CEF(Chromium Embedded Framework) with MFC Part2
이전 글(http://neodreamer-dev.blogspot.kr/2016/11/UsingCEFwithMFCPart1.html)에 기록한대로 만든 libcef_dll_warpper.dll 을 테스트하여 보았다.
테스트에 사용된 코드는 인터넷에서 CEF 사용 방법을 찾아 돌아다니다 얻은 여러 코드를 조합하여 작성한 코드인데 출처가 기억이 나지 않는다.
단순히 CEF를 올리고 구글 페이지로 접속을 하는 코드이다.
프로젝트는 다이얼로그 기반으로 기본 컨트롤을 모두 삭제하고 브라우저를 생성하기 위해 Static 컨트롤 하나만 올린 상태이다.
테스트에 사용된 코드는 인터넷에서 CEF 사용 방법을 찾아 돌아다니다 얻은 여러 코드를 조합하여 작성한 코드인데 출처가 기억이 나지 않는다.
단순히 CEF를 올리고 구글 페이지로 접속을 하는 코드이다.
프로젝트는 다이얼로그 기반으로 기본 컨트롤을 모두 삭제하고 브라우저를 생성하기 위해 Static 컨트롤 하나만 올린 상태이다.
//////////////////////////////////////////////////////////////////////////
// CEF
//#define CEF_USING_SANDBOX
#include "include/cef_app.h"
#include "include/cef_client.h"
//* CEF_3.2840.1511
#ifdef _WIN64
#ifdef _DEBUG
#pragma comment(lib, "../CEF_3.2840.1511/bin_x64/Debug/libcef.lib")
#ifdef CEF_USING_SANDBOX
// MT Only
#pragma comment(lib, "../CEF_3.2840.1511/lib_x64/Sandbox/Debug/libcef_dll_wrapper.lib")
#else
#ifdef _DLL
// MD
#pragma comment(lib, "../CEF_3.2840.1511/lib_x64/Debug/libcef_dll_wrapper_mdd.lib")
#else
// MT
#pragma comment(lib, "../CEF_3.2840.1511/lib_x64/Debug/libcef_dll_wrapper_mtd.lib")
#endif
#endif
#else // Release
#pragma comment(lib, "../CEF_3.2840.1511/bin_x64/Release/libcef.lib")
#ifdef CEF_USING_SANDBOX
// MT Only
#pragma comment(lib, "../CEF_3.2840.1511/lib_x64/Sandbox/Release/libcef_dll_wrapper.lib")
#else
#ifdef _DLL
// MD
#pragma comment(lib, "../CEF_3.2840.1511/lib_x64/Release/libcef_dll_wrapper_md.lib")
#else
// MT
#pragma comment(lib, "../CEF_3.2840.1511/lib_x64/Release/libcef_dll_wrapper_mt.lib")
#endif
#endif
#endif
#else
#ifdef _DEBUG
#pragma comment(lib, "../CEF_3.2840.1511/bin_x86/Debug/libcef.lib")
#ifdef CEF_USING_SANDBOX
// MT Only
#pragma comment(lib, "../CEF_3.2840.1511/lib_x86/Sandbox/Debug/libcef_dll_wrapper.lib")
#else
#ifdef _DLL
// MD
#pragma comment(lib, "../CEF_3.2840.1511/lib_x86/Debug/libcef_dll_wrapper_mdd.lib")
#else
// MT
#pragma comment(lib, "../CEF_3.2840.1511/lib_x86/Debug/libcef_dll_wrapper_mtd.lib")
#endif
#endif
#else // Release
#pragma comment(lib, "../CEF_3.2840.1511/bin_x86/Release/libcef.lib")
#ifdef CEF_USING_SANDBOX
// MT Only
#pragma comment(lib, "../CEF_3.2840.1511/lib_x86/Sandbox/Release/libcef_dll_wrapper.lib")
#else
#ifdef _DLL
// MD
#pragma comment(lib, "../CEF_3.2840.1511/lib_x86/Release/libcef_dll_wrapper_md.lib")
#else
// MT
#pragma comment(lib, "../CEF_3.2840.1511/lib_x86/Release/libcef_dll_wrapper_mt.lib")
#endif
#endif
#endif
#endif
//*/
//////////////////////////////////////////////////////////////////////////
BOOL CTestCEFinMFCDlg::DestroyWindow()
{
CefShutdown();
return CDialogEx::DestroyWindow();
}
BOOL CTestCEFinMFCDlg::OnInitDialog()
{
:
CRect rcBrowser;
GetDlgItem(IDC_STATIC_BROWSER)->GetClientRect(&rcBrowser);
//Create the necessary objects needed to initialize CEF
CefMainArgs cefMainArgs(theApp.m_hInstance);
CefSettings cefSettings;
CefBrowserSettings cefBrowserSettings;
CefRefPtr<CefApp> cefApplication;
CefWindowInfo cefWindowinfo;
cefSettings.multi_threaded_message_loop = true; //needed for MFC projects (unless we want to implement custom message-loop)
cefWindowinfo.SetAsChild(GetDlgItem(IDC_STATIC_BROWSER)->GetSafeHwnd(), rcBrowser);
// CefRefPtr<CefClient> client(new ClientHandler());
// m_Handler = (ClientHandler*)client.get();
//Initialize CEF
bool bSucceeded = CefInitialize(cefMainArgs, cefSettings, cefApplication, nullptr);
CefRefPtr<CefRequestContext> request_context;
CefRefPtr<CefClient> client;
if (bSucceeded)
{
CefBrowserHost::CreateBrowser(cefWindowinfo, client, L"http://www.google.com/", cefBrowserSettings, request_context);
}
:
}
2010/04/28
[Android Dev.] Custom Dialog 생성하기
Custom Dialog 를 만들어보기위해 Android Developer 사이트의 예제(http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog)를 사용해 보았는데 에러가 발생하였다.

이 문제가 발생한 것은 Dialog 생성시 생성자에 Context 를 넘겨 주도록 되어 있는데 예제에서는 getApplicationContext() 를 호출하여 Context를 가져와서 넘겨 주었는데 이 부분에 문제가 있어 보인다. Dialog 생성자 호출 부분을 this 로 넘겨주면 에러가 발생하지 않고 Dialog가 생성이 되었다.
Custom Dialog 생성에 사용한 xml layout 리소스

Android 의 Dialog 는 Title 영역과 View 영역으로 나뉘어 지며 Title 영역은 Title 을 지정하지 않아도 사라지지 않고 자리를 차지 한다. 따라서 Titlte 을 지정하지 않을 경우 아래와 같이 아무것도 표시되지 않은 영역이 남아있다.

Title 이 필요없는 경우에는 AlertDialog 를 이용하여 Dialog 를 생성하는 것도 하나의 방법이다.<
Original Post : http://neodreamer-dev.tistory.com/427
// Custom Dialog 생성 예제
Context mContext = getApplicationContext();
Dialog dialog = new Dialog( mContext );
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("Custom Dialog");
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText("Hello, this is a custom dialog!");
ImageView image = (ImageView) dialog.findViewById(R.id.image);
image.setImageResource( R.drawable.icon );
에러 발생 화면
이 문제가 발생한 것은 Dialog 생성시 생성자에 Context 를 넘겨 주도록 되어 있는데 예제에서는 getApplicationContext() 를 호출하여 Context를 가져와서 넘겨 주었는데 이 부분에 문제가 있어 보인다. Dialog 생성자 호출 부분을 this 로 넘겨주면 에러가 발생하지 않고 Dialog가 생성이 되었다.
Custom Dialog 생성에 사용한 xml layout 리소스
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:text="@+id/Button01"
android:id="@+id/Button01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
<TextView
android:text="@+id/TextView01"
android:id="@+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:text="@+id/EditText01"
android:id="@+id/EditText01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
//Context mContext = getApplicationContext();
Dialog dialog = new Dialog( this );
dialog.setContentView( R.layout.mydialog );
dialog.setTitle( "MyDialog 1" );
Button btnMyDlg = (Button)dialog.findViewById( R.id.Button01 );
btnMyDlg.setText( "My Button on Custom Dialog" );
dialog.show();
Android 의 Dialog 는 Title 영역과 View 영역으로 나뉘어 지며 Title 영역은 Title 을 지정하지 않아도 사라지지 않고 자리를 차지 한다. 따라서 Titlte 을 지정하지 않을 경우 아래와 같이 아무것도 표시되지 않은 영역이 남아있다.
Title 을 지정하지 않는 Dialog
Title 이 필요없는 경우에는 AlertDialog 를 이용하여 Dialog 를 생성하는 것도 하나의 방법이다.<
Original Post : http://neodreamer-dev.tistory.com/427
Labels:
Android
,
Android Development
,
Custom Dialog
,
dialog
,
TistoryOldPost
,
안드로이드
,
안드로이드 개발
2010/04/27
[Android Dev.] 날짜/시각 선택 대화상자 사용하기
Android 에서 기본으로 제공하는 날짜와 시각을 선택하는 대화상자를 사용하는 예이다.
날짜선택 대화상자(DatePickerDialog)와 시각선택 대화상자(TimePickerDialog) 는 해당 다이얼로그 생성해서 보여주기만 하면 되는데 이때 사용자가 설정한 날짜나 시각을 반영하기 위해서는 약간의 작업이 필요하다.
두 대화상자의 호출은 크게 차이가 없다. 차이가 있다면 다루는 데이터가 차이가 있어 나타나는 것이다. 대화상자를 생성할 때 사용자가 Set 버튼을 누를때 발생할 이벤트를 처리할 Callback 함수를 지정하여 처리하면 된다.
DatePickerDialog 생성자
public DatePickerDialog (Context context,
DatePickerDialog.OnDateSetListener callBack,
int year, int monthOfYear, int dayOfMonth)
Parameter
context : 선택 대화상자가 실행 될 Context (보통 Activity)
callBack : 사용자가 Set 버튼을 선택 했을 때 처리할 Callback 함수
year : 초기 년도
monthOfYear : 초기 월
dayOfMonth : 초기 날짜
DatePickerDialog 대화 상자를 생성할 때 넘겨주는 Callback 함수는 DatePickerDialog.OnDateSetListener 로 아래와 같은 형태를 하고 있다.
public abstract void onDateSet (DatePicker view,
int year, int monthOfYear, int dayOfMonth)
Parameters
view : The view associated with this listener.
year : 선택된 년도.
monthOfYear : 선택된 월 (0-11)
dayOfMonth : 선택 한 날짜
TimePickerDialog 생성자
public TimePickerDialog (Context context,
TimePickerDialog.OnTimeSetListener callBack,
int hourOfDay, int minute, boolean is24HourView)
Parameters
context : 선택 대화상자가 실행 될 Context (보통 Activity)
callBack : 사용자가 Set 버튼을 선택 했을 때 처리할 Callback 함수
hourOfDay : 초기 시간
minute : 초기 분
is24HourView : 24시간 사용 여부
TimePickerDialog 대화 상자를 생성할 때 넘겨주는 Callback 함수는TimePickerDialog.OnTimeSetListener 로 아래와 같은 형태를 하고 있다.
public abstract void onTimeSet (TimePicker view, int hourOfDay, int minute)
Parameters
view : The view associated with this listener.
hourOfDay : 선택 된 시각의 시
minute : 선택 된 시각의 분
날짜선택 대화상자(DatePickerDialog)와 시각선택 대화상자(TimePickerDialog) 는 해당 다이얼로그 생성해서 보여주기만 하면 되는데 이때 사용자가 설정한 날짜나 시각을 반영하기 위해서는 약간의 작업이 필요하다.
두 대화상자의 호출은 크게 차이가 없다. 차이가 있다면 다루는 데이터가 차이가 있어 나타나는 것이다. 대화상자를 생성할 때 사용자가 Set 버튼을 누를때 발생할 이벤트를 처리할 Callback 함수를 지정하여 처리하면 된다.
날짜 및 시각 선택 대화상자 호출 버튼 | 날짜 선택 대화상자 | 선택된 날짜 처리 화면 |
DatePickerDialog 생성자
public DatePickerDialog (Context context,
DatePickerDialog.OnDateSetListener callBack,
int year, int monthOfYear, int dayOfMonth)
Parameter
context : 선택 대화상자가 실행 될 Context (보통 Activity)
callBack : 사용자가 Set 버튼을 선택 했을 때 처리할 Callback 함수
year : 초기 년도
monthOfYear : 초기 월
dayOfMonth : 초기 날짜
DatePickerDialog 대화 상자를 생성할 때 넘겨주는 Callback 함수는 DatePickerDialog.OnDateSetListener 로 아래와 같은 형태를 하고 있다.
public abstract void onDateSet (DatePicker view,
int year, int monthOfYear, int dayOfMonth)
Parameters
view : The view associated with this listener.
year : 선택된 년도.
monthOfYear : 선택된 월 (0-11)
dayOfMonth : 선택 한 날짜
날짜 및 시각 선택 대화상자 호출 버튼 | 시각 선택 대화상자 | 선택된 시각 설정 화면 |
TimePickerDialog 생성자
public TimePickerDialog (Context context,
TimePickerDialog.OnTimeSetListener callBack,
int hourOfDay, int minute, boolean is24HourView)
Parameters
context : 선택 대화상자가 실행 될 Context (보통 Activity)
callBack : 사용자가 Set 버튼을 선택 했을 때 처리할 Callback 함수
hourOfDay : 초기 시간
minute : 초기 분
is24HourView : 24시간 사용 여부
TimePickerDialog 대화 상자를 생성할 때 넘겨주는 Callback 함수는TimePickerDialog.OnTimeSetListener 로 아래와 같은 형태를 하고 있다.
public abstract void onTimeSet (TimePicker view, int hourOfDay, int minute)
Parameters
view : The view associated with this listener.
hourOfDay : 선택 된 시각의 시
minute : 선택 된 시각의 분
TextView tvDate;
Button btnDate;
TextView tvTime;
Button btnTime;
Calendar calDateTime = Calendar.getInstance();
// Date Set Listener
DatePickerDialog.OnDateSetListener dateSetListener =
new DatePickerDialog.OnDateSetListener()
{
@Override
public void onDateSet( DatePicker view, int year, int monthOfYear,
int dayOfMonth )
{
calDateTime.set( Calendar.YEAR, year );
calDateTime.set( Calendar.MONTH, monthOfYear );
calDateTime.set( Calendar.DAY_OF_MONTH, dayOfMonth );
String strDate;
strDate =
Integer.toString( year ) + "/" +
Integer.toString( monthOfYear ) + "/" +
Integer.toString( dayOfMonth );
tvDate.setText( strDate );
}
};
// Time Set Listener
TimePickerDialog.OnTimeSetListener timeSetListener =
new TimePickerDialog.OnTimeSetListener()
{
@Override
public void onTimeSet( TimePicker view, int hourOfDay, int minute )
{
calDateTime.set( Calendar.HOUR_OF_DAY, hourOfDay );
calDateTime.set( Calendar.MINUTE, minute );
String strTime;
strTime =
Integer.toString( hourOfDay ) + ":" +
Integer.toString( minute );
tvTime.setText( strTime );
}
};
:
tvDate = (TextView)findViewById( R.id.TVDate );
btnDate = (Button)findViewById( R.id.BtnDate );
btnDate.setOnClickListener( this );
tvTime = (TextView)findViewById( R.id.TVTime );
btnTime = (Button)findViewById( R.id.BtnTime );
btnTime.setOnClickListener( this );
:
case R.id.BtnDate:
{
// Call Date Picker
new DatePickerDialog(
MyDialog.this,
dateSetListener,
calDateTime.get( Calendar.YEAR ),
calDateTime.get( Calendar.MONTH ),
calDateTime.get( Calendar.DAY_OF_MONTH )
).show();
}
break;
case R.id.BtnTime:
{
// Call Time Picker
new TimePickerDialog(
MyDialog.this,
timeSetListener,
calDateTime.get( Calendar.HOUR ),
calDateTime.get( Calendar.MINUTE ),
true
).show();
}
break;
}
:
Original Post : http://neodreamer-dev.tistory.com/426
Labels:
Android
,
Android Devlopment
,
DatePickerDialog
,
dialog
,
TimePickerDialog
,
TistoryOldPost
,
날짜 선택
,
대화상자
,
시각 선택
,
안드로이드
,
안드로이드 개발
2008/10/13
Dialog 위에 ScrollView 올리기
////////////////////////////////////////////////////////////////////////
//On View
//header
public:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName
, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd
, UINT nID, CCreateContext* pContext = NULL);
//source
BOOL CSampleView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName
, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd
, UINT nID, CCreateContext* pContext)
{
return CWnd::Create(lpszClassName, lpszWindowName,
dwStyle, rect, pParentWnd, nID, pContext);
}
int CSampleView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest
, UINT message)
{
return MA_ACTIVATE;
//return CScrollView::OnMouseActivate(pDesktopWnd, nHitTest, message);
}
////////////////////////////////////////////////////////////////////////
//On Dialog
CRect rt;
GetClientRect(rt);
m_pScrollView = new CSampleView();
m_pScrollView->Create (NULL, NULL, WS_VISIBLE | WS_CHILD,
rt, this, 10000, NULL);
CSize sizeTotal;
sizeTotal.cx = sizeTotal.cy = 100;
m_pScrollView->SetScrollSizes(MM_TEXT, sizeTotal);
Original Post : http://neodreamer-dev.tistory.com/182
Labels:
C++
,
dialog
,
MFC
,
ScrollView
,
TistoryOldPost
Subscribe to:
Posts
(
Atom
)
