|
Hello,
I'm an experienced programmer, but can't seem to find the info I need. I'd like to add a new option to the 'right-click' menu in internet explorer so rather than performing a 'save as' command I can send GIFs and JPEGs directly to an art program I've written. Is this possible? Perhaps this is a COM or OLE function?
thanks.
|
|
|
|
|
|
I'm using the DrawText API, and passing in DT_CALCRECT to query the size of the text.
It works well, but when the font it is italic, and I draw it into the rect returned, it gets cut off by a few pixels!
Below is VB sample code that shows the problem.
Has anyone else seen this? am i doing something wrong? Is this a bug?
Thanks!
- Alex
' Font:
Private Const LF_FACESIZE = 32
Private Type LOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName(LF_FACESIZE) As Byte
End Type
Private Const FW_NORMAL = 400
Private Const FW_BOLD = 700
Private Const FF_DONTCARE = 0
Private Const DEFAULT_QUALITY = 0
Private Const DEFAULT_PITCH = 0
Private Const DEFAULT_CHARSET = 1
Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long
Private Declare Function MulDiv Lib "kernel32" (ByVal nNumber As Long, ByVal nNumerator As Long, ByVal nDenominator As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Const LOGPIXELSY = 90
' Testing the font:
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
Private Const DT_CALCRECT = &H400
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
Public Sub Test(ByVal hdc As Long, fntThis As StdFont)
Dim tLF As LOGFONT
Dim hFnt As Long
Dim hFntOld As Long
Dim tR As RECT
' Create a LOGFONT structure equivalent to the
' StdFont font:
pOLEFontToLogFont fntThis, hdc, tLF
' Convert the LOGFONT into a font handle:
hFnt = CreateFontIndirect(tLF)
' Test the font out:
hFntOld = SelectObject(hdc, hFnt)
DrawText hdc, "NIPIGON", -1, tR, DT_CALCRECT
OffsetRect tR, 32, 32
DrawText hdc, "NIPIGON", -1, tR, 0&
SelectObject hdc, hFntOld
' Always remember to delete the font when finished
' with it:
DeleteObject hFnt
End Sub
Private Sub pOLEFontToLogFont(fntThis As StdFont, ByVal hdc As Long, tLF As LOGFONT)
Dim sFont As String
Dim iChar As Integer
Dim b() As Byte
' Convert an OLE StdFont to a LOGFONT structure:
With tLF
sFont = fntThis.Name
b = StrConv(sFont, vbFromUnicode)
For iChar = 1 To Len(sFont)
.lfFaceName(iChar - 1) = b(iChar - 1)
Next iChar
' Based on the Win32SDK documentation:
.lfHeight = -MulDiv((fntThis.Size), (GetDeviceCaps(hdc, LOGPIXELSY)), 72)
.lfItalic = fntThis.Italic
If (fntThis.Bold) Then
.lfWeight = FW_BOLD
Else
.lfWeight = FW_NORMAL
End If
.lfUnderline = fntThis.Underline
.lfStrikeOut = fntThis.Strikethrough
.lfCharSet = fntThis.Charset
End With
End Sub
Private Sub Command1_Click()
Dim sFnt As New StdFont
sFnt.Name = "Copperplate Gothic Bold"
sFnt.Size = 48
sFnt.Bold = True
sFnt.Italic = True
Test Me.hdc, sFnt
End Sub
|
|
|
|
|
this is how I use CALCRECT:
RECT pos = {0,0,0,0};
long len = strlen(text);
::DrawText(TmpDC,text,len,&pos,DT_CALCRECT);
pos.right+=pos.bottom;
|
|
|
|
|
Thanks for the response Davide.. so I take it you've had the same problem? I came up with a similar solution:
GetTextMetrics i_lHDC, metrics
If metrics.tmItalic <> 0 Then
lActualWidth = lActualWidth + metrics.tmAveCharWidth
End If
Basically I increase the width of the rect by the average character width if it is italic.
|
|
|
|
|
Hi,
I want to be able to do something like this ...
<br />
MyView::MyView( int w, int h) <br />
{<br />
...<br />
pDoc->m_buffer = malloc ( w * h );<br />
for ( int i=0; i<w; i++ ) {<br />
for ( int j=0; j<h; j++ ) {<br />
p_Doc->m_buffer[i][j] = PI * some_random();<br />
}<br />
}<br />
...<br />
}<br />
... my question is how should I declare m_buffer in my MyDoc class?
I thought I would do this ...
<br />
class MyDoc : public CDocument<br />
{<br />
...<br />
public:<br />
double m_buffer[][];<br />
...<br />
}<br />
but that don't compile. Please help!
|
|
|
|
|
Anonymous wrote:
double m_buffer[][];
replace by double** m_buffer ?
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
After I have converted a project from VC++ 6 to VC++7 (Visual Studio .NET). I tried to rebuild the project. I received this error message:
Command line error D2016 : '/O2' and '/RTC1' command-line
options are incompatible
Is this common? I looked up D2016 from Help menu and found this:
Visual C++ Concepts: Building a C/C++ Program
Command-Line Error D2016
'option1' and 'option2' Command-line options are incompatible
The command-line options cannot be specified together.
Example
cl /Gw /NDxx program.c
In this example, the /Gw and /NDxx options are incompatible
because each has a different special-entry sequence.
Check the CL or FL environment variable for option
specifications
I don't have command line with syntax cl /.... in my source code. Please help.
-Elizabeth
Eilzabeth
|
|
|
|
|
menu Project->Properties
Configuration Properties->C/C++->Command Line
remove /RTC1
|
|
|
|
|
hey all,
say you have CSocket, or a plain WSA socket as a pointer member of a class, and you block the socket on a read method, and while it's blocked, you pass a reference to the class containing the socket to another thread through a casted pointer through the LPVOID pParam of a thread message,
THEN, you start doing other operations on the CSocket from thread 2 through the pointer, while thread 1 has the thread on the blocked receive method.
Like say thread 1 has the socket blocked receiving and thread 2 does a send on the same instance of the class with the m_pcsocket???
Does the world suddenly blow up if that happens?
I used to do this all the time with java, but I'd like to know if it will properly work before I try it with CSocket.
hey
|
|
|
|
|
No. I think given that a socket is blocked, you have to wait for the thread to free the socket. One solution is WSA non-blocking model. WSA modes will return immediately and allows any other threads to process the socket.
Kuphryn
|
|
|
|
|
"void CancelBlockingCall( );
Remarks
Call this member function to cancel a blocking call currently in progress."
This is nuts, how are you going to cancel a blocking call if the call is blocked?
They HAVE to mean from another thread right?
Then you can cancel the receive before you send text then restart it right after your data is sent right?
am i wrong or am i right?
hey
|
|
|
|
|
MFC CSockets can't be passed between threads. It should be possible with a plain WinSock socket.
|
|
|
|
|
It turned out I was actually looking for CSocket's OnReceive function, overriding that gave the class i was writing the desired effect.
hey
|
|
|
|
|
I have a CEdit control defined like so:
EDITTEXT IDC_LOG,7,177,437,86,ES_MULTILINE | ES_AUTOVSCROLL | <br />
ES_READONLY | WS_VSCROLL<br />
I add text to it like this:
bool CFLModManagerDlg::Log(CString text, bool NewLine)<br />
{<br />
LogString += text;<br />
if(NewLine)<br />
LogString += "\r\n";<br />
UpdateData(FALSE);<br />
LogCtrl.SetSel(0,-1,FALSE);<br />
return false;<br />
}<br />
Now, no matter what I do to try to make it scroll to the bottom, it won't! What am I doing wrong?
|
|
|
|
|
I Got an own custom controller.
Lets call it.
class CMyCtrl , public CWnd
{
public:
// ...
//
private:
CButton m_Btn;
};
and this controller creates the CButton ( m_Btn ) inside CMyCtrl dynamically.
How can CMyCtrl know if m_Btn is clicked ??
I Can subclass CButton and overload OnLButtonUp() and to
GetParent()->SendMessage(…) but I don’t want to. There must be a way to get CMyCtrl to get the information that a child window has been click or ??
|
|
|
|
|
Does anyone know if it is a fact that ActiveX components such as a DataGrid on a Dialog breaks DialogBoxParam such that WM_INITDIALOG never gets called but instead immediately shuts-down (WM_DESTROY) the Dialog?
I am using code that does not use MFC. A friend says that COM (ActiveX) does NOT work in a non-MFC environment. Is there a workaround???
Thanks --
|
|
|
|
|
I am trying to do something simple. A user types in a share name of a resource (e.g., \\Mycomputer\MyShare), and I want to validate it to make sure the resource actually exists before going any further.
Apparently, nobody else does this, becuase the documentation for all the Microsoft networking APIs sucks, and there are very few examples on the Net (I couldn't find anything relevant). Here are some of the things I've tried to do so far:
resource.dwType = RESOURCETYPE_PRINT;
resource.lpRemoteName = uncShareName.GetBuffer(0);
size = 0;
error = ::WNetGetResourceInformation(&resource, NULL, &size, NULL);
I always get error code 487 - Invalid address. (Of course, MSDN does not list this as an error that WNetGetResourceInformation should return.)
So then, I tried seeing if I could set the NETRESOURCE's lpProvider and perhaps that would make things go smoother. But this simple code:
DWORD size = 1000;
char provider[1000];
DWORD error;
error = ::WNetGetProviderName(WNNC_NET_MSNET, provider, &size);
always returns an error 1222, network cannot be found (network not present or cannot be found). Apparently my network type is wrong, but there are no others that look anywhere near correct.
For printers, I can use EnumPrinters and get it to work - but only if the remote server is Windows NT, 2000, or XP. It gives me an error, RPC Server unavailable, if I try to look for shares on a 9X machine.
One final piece of the puzzle - I know it is not a networking issue, becuase I can see any object I want using Windows Explorer or "Run" from the Start menu.
Any help would be appreciated.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
Ah, nevermind, I figured it out. The key is to use WNetEnumResources.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
I am trying to find a way to display a form from a
Visual studio macro. I have opened the Macro IDE,
but cannot find a way to insert a form. Can anyone
tell me how to do this, or do I need to build an
add in for such a thing? (Coding the macro in VB)
Thanks,
NDP.
|
|
|
|
|
As far as I know, it's not possible in VC6. An add-in is your only option.
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
I'm sorry, I should have been more specific. I am using
Visual Studio .Net
|
|
|
|
|
The story so far...
Using MSVC 6.0, I've created an MDI MFC application, and selected "Container" compound document support. I also ticked the Active Document container checkbox.
I run the application, and insert an object from a file - an existing Word document - into my document. As expected, it shows the whole Word document in the application.
I then select Print Preview from the menu. The print preview window comes up, showing an empty document. The document content is now spewing out of my printer
So, does anyone know how to fix this so the content goes to the print preview DC, not the printer DC?
Thanks in advance
|
|
|
|
|
Hi,
I am trying to get XP alpha icons working in a ListView. I have created a manifest file which link to comctrl 6 but the XP style icons come out crappy. I have noticed in .NET there is a FlatStyle property that you need to set to FlatStyle.System to get it to work correctly.
How can I make XP Icons show correctly in MFC?
Thanks
Ceri
|
|
|
|
|
I have a bunch of local MyCDlg windows that I made using: MyCDlg* pDlg = new MyCDlg that have their pointers in a stored in a vector. At some point I want to kill all these windows so I cycle through the vector and do
pVec[i]->DestroyWindow()
Right after the destroy is it okay to do "delete pVec[i];" ? Is that the way to do it?
Appreciate your help,
ns
|
|
|
|
|