|
I have downloaded Windows Script Engine(5.6). It is enough to
apply the ActiveX scripting to my MFC Application.I want to create the
com component and want to link with this my MFC program.
|
|
|
|
|
Hi,
I am developing an application in MFC/VC++ 6.0. I need to draw a bitmap image in a dockable toolbar and the view area should have scrolling enabled.
I thought that embedding a CScrollView derived class in the dialog box would help while declaring a custom control as the placeholder while designing the dialog box.
However, I don't know how to manually wire in the CScrollView class. I even don't know whether there is any easier way to do this.
Please help.
Thanks in advance.
|
|
|
|
|
Hi!
I'm developing an application using MFC. I've implemented Context sensitive help for the controls but is unable to do so for edit box.
In case of edit box, on right click of the mouse it displays the default help in place of my help.
Kindly help me on this,
Thanks
Pawan
|
|
|
|
|
I guess in Context Sensitive help, you cannot right click.
For a proper Context Sensitive help - click on the question mark on toolbar, the question mark gets attached to your mouse pointer and left click on the control for which you need help info.
Either a small popup window opens or a html page opens to provide information
First you should choose whether you want html context sesitive help or windows context sensitive help
Then override the respective virtual functions
|
|
|
|
|
hiho@ll
what i have:
a HBITMAP handle
no parent window
a browser helper object, which should do the job
what i need:
the upper left pixel of the HBITMAP handle
what i think how it could work: (well it doesn't work )
CWindow *tmpwin=new CWindow(::GetDesktopWindow()); // i don't have a parent
HDC hdc=tmpwin->GetDC();
SelectObject(hdc,hbmp); // select the HBITMAP
COLORREF cf=GetPixel(hdc,0,0);
return cf;
what i get:
the return RGB Values are 255,255,255
using GetLastError after the GetPixel and before Return i get ErrorCodes 6 and 8 (invalid handle, not enough space)
i'm calling the method a few times, so i get some error codes and not just one
question:
how can hdc be an invalid handle, if i use GetDesktopWindow?
how can i get "not enough space" for a bitmap which is 16x16?
a workaround i'm thinking of, but i don't know how to do:
i make my own window, use selectobject on my window, get the pixel, and destroy the window
question:
how can i make my own window? (some code would be great)
and how do i destroy the window?
btw, the only purpose of this window will be to get a valid DC to select the HBITMAP and get the pixel
thx@ll
|
|
|
|
|
Hello,
Me again! I was searching through MSDN and found the following functions usefull for your problem:
<list>GetDC() [^] for retrieving the DC of the desktop.
CreateCompatibleDC()</a>[<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceshellui5/html/wce50lrfCreateCompatibleDC.asp" target="_blank" rel="nofollow" title="New Window">^</a>] for creating a memory DC<br />
<li> <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_9v3o.asp" rel="nofollow"><code>SelectObject() [^] for placing the bitmap in the DC (Note that the bitmap can only be selected in one DC at a time!)
Using these functions, one can do the following:
HDC hMemDC = ::CreateCompatibleDC(GetDC(NULL));
HGDIOBJ hOldObj = ::SelectObject(hMemDC, hbmp);
COLORREF cf = GetPixel(hMemDC, 0, 0);
::SelectObject(hMemDC, hOldObj);
::DeleteDC(hMemDC);
return cf;
Hope this helps
P.S.
Some of your problems could be: tmpwin has no DC, which results in invalid handle errors, hbmp is already selected in a DC, hbmp is not created correctly,..
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
hiho
tried your code
the same problem
tried to make my own window with CreateWindow("STATIC",NULL,WS_CHILD|WS_VISIBLE,0,0,16,16,NULL,(HMENU)NULL,g_hThisModule,NULL);
the same problem
hmm
1. how do i know if the window has a DC?
2. how do i check if hbmp is already selected? (hmm, i don't think it is, but how do i check, just to be sure?)
|
|
|
|
|
ThinkingPrometheus wrote:
1. how do i know if the window has a DC?
All windows have a DC, as long as they are visible. I don't know if they have a DC when they are invisible.
ThinkingPrometheus wrote:
2. how do i check if hbmp is already selected? (hmm, i don't think it is, but how do i check, just to be sure?)
From where do you get the handle? I think the problem lies there, since all the other windows and dc's should be valid.
You can validate this by loading your own bitmap from disk and see what that gives you.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
hiho@ll
i have to convert a string from Variant to CString (or LPCTSTR)
i read some articles about bstr conversion, but doesn't seem to work
1. i have a variant variable
2. i want to use MessageBox to show the Variant-String
how do i do this?
some code would be perfect
thx
|
|
|
|
|
I'll help with the conversion (I'm sure you can handle the MessageBox!)
CString GetString(const VARIANT* pvaData)
{
if (pvaData->vt == VT_BSTR)
return pvaData->bstrVal;
if (pvaData->vt == (VT_BSTR | VT_BYREF))
return *pvaData->pbstrVal;
if (pvaData->vt == (VT_VARIANT | VT_BYREF))
return GetString(pvaData->pvarVal);
VARIANT varDest;
VariantInit(&varDest);
if (SUCCEEDED(VariantChangeTypeEx(&varDest, (VARIANT*) pvaData, LOCALE_SYSTEM_DEFAULT, 0, VT_BSTR)))
return GetString(&varDest);
return _T("");
}
|
|
|
|
|
Check here[^]
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
wow
cool
thx to both of you
|
|
|
|
|
hi
you can take the variable of bstr type and assign variant to the bstr and then pass the bstr value in messagebox .
It works
cheers
|
|
|
|
|
If you know that the VARIANT contains a BSTR you can get the BSTR , which is really a special form of a wide-character string, and pass it to the wide-character version of MessageBox :
MessageBoxW( hWndParent, vtMyVariant.bstrVal, L"The Caption", ( MB_ICONINFORMATION | MB_OK ) )
(You could also pass in a dereferenced pbstrVal .)
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi..
I have a problem with my VC++ code,
the problem is i don't know how to send my calculation from Doc file to dialog file. I keep getting errors.
Here are my code in Dialog class :
void ImgViewerDlg::OnUpdate(CView *pSender, LPARAM lHint, CObject *pHint)
{
CImgViewerDoc *pDoc =GetDocument();
ASSERT_VALID(pDoc);
sasa = static_cast<cstring>(pDoc->jarak);
m_Angle = sasa;
}
void ImgViewerDlg::OnApply()
{
UpdateData(TRUE);
CImgViewerDoc *pDoc = GetDocument();
ASSERT_VALID(pDoc);
sasa = m_Distance;
}
the errors are :
mgViewerDlg.obj : error LNK2001: unresolved external symbol "protected: class CImgViewerDoc * __thiscall ImgViewerDlg::GetDocument(void)" (?GetDocument@ImgViewerDlg@@IAEPAVCImgViewerDoc@@XZ)
maybe it something to do with the declaration of Doc class. please help me..I want to sent my calculation from Doc to view in textbox on a dialog.
Thank in advance.
mafuza
|
|
|
|
|
mafuza wrote:
void ImgViewerDlg::OnUpdate(CView *pSender, LPARAM lHint, CObject *pHint)
Is this a CDialog or CView class ?
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
sorry late reply because internet connection down.
for your question the answer is CDialog class.
so any suggestion?
|
|
|
|
|
Defination for GetDocument is missing, Implement this in your ImgViewerDlg class and it should work fine.
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
Hello!
Can anyone tell me what is an easiest way to show some picture file (say .bmp) on dialog based application in Visual C++?
Best regards,
Rostfrei
|
|
|
|
|
Using CStatic would server your purpose.
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
CStatic how? Can you please write 1 or 2 line of example code?
Regards,
Rostfrei
|
|
|
|
|
on you dialog editor, paste a bitmap control on your dialog... it is actually a CStatic control...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Check this[^]
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
I created 2 sliders in my dialog box. The problem now is that i can only set the range in whole number.eg (0-100). I need to set it in float .eg (0-1) Can anyone help me out?Below is part of my program.
BOOL GrowDialogBox::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_slider3.SetRange(0,1);
m_slider3.SetTicFreq(0.01);
m_slider4.SetRange(0,1);
m_slider4.SetTicFreq(0.01);
minnSliderPos = 0;
maxxSliderPos = 1;
// For displaying numbers on the box
s3.Format("%f",0); // Set it to 0 for min and 1 for max
m_EDIT3.SetWindowText(s3);
s4.Format("%f",1);
m_EDIT4.SetWindowText(s4);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
My warning received is
warning C4244: 'argument' : conversion from 'const double' to 'int', possible loss of data
|
|
|
|
|
First off, the control does not allow float parameter. Once this is known, you can stop trying to fit that square peg in that round hole.
What you will need to do, and I suspect other have done, is to scale your input to an appropriate integer range.
So lets say that you want your slider to show be in the range 0 - 0.1. Then what you can do is multiply all your values by 100, and set the slider range to be 0-100. Use the reverse technique when retrieving values from the slider (divide by 100, to get the true value).
Hope this helps
I Dream of Absolute Zero
|
|
|
|