|
thx for your help
but i don't want to use the scrollbar of CHtmlView, there are a lot of problem with there (i can't control scrollbar with some web site). I search a function like "ScrollTo(X,Y) " but it seems it doesn't exist
thank you nevertheless
|
|
|
|
|
Hi
I'm using hooks to subclass menus so I can draw them myself. This works pretty good on Windows XP, but on 98 and 2000 it only seems to work once. When I have two different programs using the new style menus I can start up one of them over and over again without problems. But as soon as I click on a menu in another app using the menus it crashes. It only happens with a menu attached to a window. When using TrackPopupMenu it always seems to work. Any suggestions?
Thanks
|
|
|
|
|
i want to know how to replace simple buttons with bitmaps.
I dont want to use derived classes or CBITMAPBUTTON .
I tried using CButton::Setbitmap but it wasnt working.
Please explain thoroughly how to do it.
|
|
|
|
|
hi yashraj,
The method for using CBitmapButton class is clearly mentioned in MSDN.
To include a bitmap-button control in a dialog box, follow these steps:
1. Create one to four bitmap images for the button.
2. Create a dialog template with an owner-draw button positioned where you want the bitmap button. The size of the button in the template does not matter.
3.Set the button’s caption to a value such as “TEST” and define a symbol for the button such as IDC_TEST.
4.In your application’s resource script, give each of the images created for the button an ID constructed by appending one of the letters “U,” “D,” “F,” or “X” (for up, down, focused, and disabled) to the string used for the button caption in step 3. For the button caption “TEST,” for example, the IDs would be “TESTU,” “TESTD,” “TESTF,” and “TESTX.” You must specify the ID of your bitmaps within double quotes. Otherwise the resource editor will assign an integer to the resource and MFC will fail when loading the image.
5.In your application’s dialog class (derived from CDialog), add a CBitmapButton member object.
6.In the CDialog object’s OnInitDialog routine, call the CBitmapButton object’s AutoLoad function, using as parameters the button’s control ID and the CDialog object’s this pointer.
Mahesh Varma
|
|
|
|
|
ALREADY TOLD THAT I DONT WANT TO USE " CBitmapButton "
|
|
|
|
|
Is there any way of changing style of a dialog box from not resizable to resizable and back at run-time?
Regards,
Vitaly Tomilov
Professional tooltips for all development platforms Free on www.Tooltips.NET
|
|
|
|
|
Try SetWindowLong(GetSafeHwnd(), GWL_STYLE, (LONG)WS_THICKFRAME)
for sizable and with WS_DIALOGFRAME for non resizable
|
|
|
|
|
I tried that, but what happens – non-resizable dialog acquires a border for sizing alright, and the mouse cursor changes on such border, but the dialog box still won't resize
Regards,
Vitaly Tomilov
Professional tooltips for all development platforms Free on www.Tooltips.NET
|
|
|
|
|
Sure that it can be done, but I don't know how...
but, if nobody answers you, you can handle the resizing event and let all the dialogs as resizable, if your condition is true (you should be able to process the resizing) then you allow the WM_Size message to be processed, if your condition is not OK, then you can avoid the resizing in the same handler...
HTH...
|
|
|
|
|
It's all theory. Once I change style of the dialog box to be resizable it does't start recieving WM_SIZE anyway.
Regards,
Vitaly Tomilov
Professional tooltips for all development platforms Free on www.Tooltips.NET
|
|
|
|
|
Sorry, it's not theory... it works well, I used it in many of my applications, not in your pourpose, but after all it can be used for that...
you must be doing something incorrectly...
the WM_SIZE message is received during the resizing operation of the dialog (always that the dialog is getting resized...).
if you want, I will send you some code that handles the resizing and that conditionates it...
|
|
|
|
|
I would appreciate if you could send it on vitaly@cylon.ie
Thanx!!!
Regards,
Vitaly Tomilov
Professional tooltips for all development platforms Free on www.Tooltips.NET
|
|
|
|
|
|
I've found it... it's only a function so I won't e-mail you... hare you have it:
void CDialogResDlg::OnSizing(UINT fwSide, LPRECT pRect)
{
if (!this->bAllowResizing)
{
if (pRect->bottom - pRect->top != 400) pRect->bottom = pRect->top + 400;
if (pRect->right - pRect->left != 400) pRect->right = pRect->left + 400;
}
CDialog::OnSizing(fwSide, pRect);
}
remember to choose the resizing border in the dialog editor properties...
Hope this helps...
|
|
|
|
|
Hi,
I'm using GetStockObject with SYSTEM_FONT to get the Tahoma font on Win2k/XP, as it's described on its documentation ; why does it return a different font face (and size) ?
|
|
|
|
|
|
I know that in and SDI project normally exists only
a DOC and a VIEW at the same time.
I need to develop a project where I can change some
different views for the same document in order to manage
a not easy UI (lots of controls...).
In this way... I have found the following function:
BOOL CMysDoc::SwitchToView(CRuntimeClass* pNewViewClass)
{
CFrameWnd* pMainWnd = (CFrameWnd*)AfxGetMainWnd();
CView* pOldActiveView = pMainWnd->GetActiveView();
// If we're already displaying this kind of view, no need to go further.
if (pOldActiveView->IsKindOf(pNewViewClass))
return TRUE;
// Set the child window ID of the active view to AFX_IDW_PANE_FIRST.
// This is necessary so that CFrameWnd::RecalcLayout will allocate
// this "first pane" to that portion of the frame window's client
// area not allocated to control bars. Set the child ID of
// the previously active view to some other ID.
::SetWindowLong(pOldActiveView->m_hWnd, GWL_ID, 0);
// create the new view
CCreateContext context;
context.m_pNewViewClass = pNewViewClass;
context.m_pCurrentDoc = this;
CView* pNewView = STATIC_DOWNCAST(CView, pMainWnd->CreateView(&context));
if (pNewView != NULL)
{
// the new view is there, but invisible and not active...
pNewView->ShowWindow(SW_SHOW);
pNewView->OnInitialUpdate();
pMainWnd->SetActiveView(pNewView);
pMainWnd->RecalcLayout();
// destroy the old view...
pOldActiveView->DestroyWindow();
pOldActiveView = NULL;
return TRUE;
}
return FALSE;
}
Using this function I can easily change the current View
but at least one problem remains...
This function destroyes the old view so in my application
exists only one view at the same time.
This causes the not-possibility to centralize Views management.
I'd like to create all views at the start of my application
and to manage all of them in the same time (showing
only one and changing the visualized one when is required).
Is it possible to do that ??
Or only one view can exixts in the SDI project ??
I have also tried to use a sequence of the following instructions
in order to create all views at the start of the application:
// create the new view
CCreateContext context;
context.m_pNewViewClass = pNewViewClass;
context.m_pCurrentDoc = this;
CView* pNewView = STATIC_DOWNCAST(CView, pMainWnd->CreateView(&context));
But it seems to doesn't work !!!
Can someone help me ??
Thanks a lot !!
|
|
|
|
|
Take a look at the other article from the same guy !
You can find it on this site in the Doc/view section. Look at "Switching to other view in a doc-view application".
I used it and I think it's just what you need!
Hope this helps
|
|
|
|
|
Hi, How do i convert Device Units to Pixels?
|
|
|
|
|
Try looking at CDC::DPToLP() .
|
|
|
|
|
|
Hi !
I have a file containing a lot of data (so the file is quite big also) and I want to change the firsts characters in it. In fact, these characters are a counter for blocks of data in the file. So, when I add data, I have to increment this counter but how can I do it without reading all the file, replace the number in memory and write all the file again??? I just want to change the counter and add data at the end of the file!
Any suggestions??
Thanks
|
|
|
|
|
Hi there ... hope that code snippet will help
CString csFile = "c:\\temp\\test.dat";
CFile f;
CFileException e;
TRY
{
// open the file for read/write-access
if(f.Open( csFile, CFile::shareExclusive | CFile::modeReadWrite , &e ) )
{
// read the ... bytes, where the counter is located ....
char pszLine[255] = "";
memset( pszLine, 0, sizeof( pszLine ) );
UINT nBytesRead = f.Read( pszLine, 255 );
// modify the content of the read buffer here ....
// for example : you may increment your data counter
:
:
// write modified buffer content back
f.SeekToBegin();
f.Write( pszLine, nBytesRead );
// move to the end of file and write new data
char pszNewData[1024] = "";
memset( pszNewData, 123, sizeof( pszNewData ) );
f.SeekToEnd();
f.Write( pszNewData, sizeof( pszNewData ) );
f.Close();
}
}
CATCH( CFileException, e )
{
#ifdef _DEBUG
afxDump << "File could not be opened " << e->m_cause << "\n";
#endif
}
END_CATCH
|
|
|
|
|
Use CFile::Seek() to get to the point in the file at which you wish to write.
For example
CFile fileDemo("C:\\Demo.bin", CFile::modeReadWrite | CFile::modeCreate | CFile::modeNoTruncate | CFile::shareDenyWrite);<br />
<br />
long lValue = 123456;<br />
<br />
fileDemo.Seek(OFFSET_FROM_BEGINNING, CFile::begin);<br />
fileDemo.Write(&lValue, sizeof(long));
|
|
|
|
|
Thanks guys !!!
It's exactly what I was looking for
|
|
|
|