|
Here is some code for the conversion:
CDC* pDC = CDC::FromHandle(::GetDC(NULL));
Gdiplus::Graphics g(pDC->m_hDC);
Gdiplus::Font gdipFont(L"Arial", (REAL)8);
LOGFONT lf;
#ifdef _UNICODE
gdipFont.GetLogFontW(&g, &lf);
#else
gdipFont.GetLogFontA(&g, &lf);
#endif
CFont font;
font.CreateFontIndirect(&lf);
Hope this helps!
modified on Tuesday, February 17, 2009 9:25 AM
|
|
|
|
|
Hey everybody
I am REALLY stuck with this one!
I'll describe the problem with a scenario:
(1) Log to computer with user "A".
(2) start->run-> "\\somecomp\somedir\"
(3) user "A" has no access to this "\\somecomp\somedir\", thus windows pops up a window that allows user "A" to log-in to "\\somecomp\somedir\" as a different user.
(4) user "A" enters user/pass of "P" that has permission to the "\\somecomp\somedir\".
The question is:
How can I tell (from user "A"'s computer) that he uses user "P" to get to "\\somecomp\somedir\" ????
Help... please...
Thanks!
|
|
|
|
|
Hi,
in my app I have the following code:
std::ofstream f(sPath.GetBuffer(0), std::ios::binary);
f.write((const char *) pBytes, dwSize);
f.close();
I also include 'iostream.h' #include <iostream.h></iostream.h>
I'm getting error:
-error C2027: use of undefined type 'basic_ios<char,struct> >'
-error C2065: 'binary' : undeclared identifier
-error C2079: 'f' uses undefined class 'basic_ofstream<char,struct> >'
-error C2078: too many initializers
-error C2228: left of '.write' must have class/struct/union type
-error C2228: left of '.close' must have class/struct/union type
Help?
Thanks!
P.S. Using vc++ 6 on WinXP SP3
|
|
|
|
|
josip cagalj wrote: I also include 'iostream.h'
You should include <fstream> also. And iostream.h is deprecated, you should include <iostream> instead (without the .h).
|
|
|
|
|
|
Still one thing more,
how to test why std::ofstream failed.
My code:
std::ofstream f(sPath.GetBuffer(0), std::ios::binary);
fails to open file, I test that with f.is_open() , but why?
Thanks
|
|
|
|
|
Check the path you're supplying to the ofstream constructor - this little C++ program works for me, which demonstrates the library doing the right thing:
#include <iostream>
#include <fstream>
int main(int, char**)
{
std::ofstream f("a.a", std::ios::binary);
if (!f.is_open())
{
std::cerr << "File open failed" << std::endl;
}
else
{
f << "Hello";
f.close();
}
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
josip cagalj wrote: I also include 'iostream.h'
As well as adding in #include <fstream> , let's change that #include <iostream.h> to #include <iostream> - that's what you should be including for standard stream support
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks to you also.
Please see my new post.
|
|
|
|
|
I’ve got problem with using GDI on top of OpenGL in Windows Vista. I’ve found that if GDI graphic would be drawn before any drawing operation of OpenGL than everything what was drawn by GDI would be cleared and would be drawn everything what was drawn by OpenGL before and after. It looks like OpenGL is drawn in separate buffer which after each calling of glFlush function drawn on a screen while clearing what was drawn by GDI. One of easiest solution of the problem is to draw any GDI objects after drawing OpenGL elements, but appears the same problem when the screen spitted on 4 sides. After drawing of one screen, drawing of OpenGL elements next screen clearing GDI objects previous screen. I tried to draw everything on the screen and the copy everything to memory buffer using CDC::BitBlt and then draw this buffer using OpenGL function glDrawPixels. But I found that GDI objects are drawn after exit from CView::OnDraw function, means catch of screen using CDC::BitBlt at the end of CView::OnDraw function do not include GDI objects.
Other case is to draw GDI objects to memory and the draw them by using OpenGL functions did not tested. I am trying to find much easiest way to solve the problem.
Please, help to solve the problem.
|
|
|
|
|
Hi,
I want to move one line between two horizontal sliders, with respect to slider position... I am able to move slider tic, but not able to move line to exact sliders tic...
Is there any way to get pixels information from the slider control..
If so please kindly let me know ... It is very urgent requirement for me..
Thanks in advance..
modified on Tuesday, February 17, 2009 10:17 AM
|
|
|
|
|
It should be possible to use GetWindowRect on the slider control to get the total width of the slider and then the GetPos method to get the current tic position to calculate the width of the line you want to draw.
«_Superman_»
|
|
|
|
|
Hi,
I have tried with your solution, I am calling m_pDlg->m_slider_bar1.GetWindowRect(&rect1); this control from my app for getting pixels position.
after that i am trying to change the slider position like below mentioned way:
int pos = m_pDlg->m_slider_bar1.GetPos();
m_pDlg->m_slider_bar1.SetPos(slide_pos);
m_pDlg->m_slider_bar2.SetPos(slide_pos);
every time i am getting rectangle pixels like :- 86,110,283,565 only.
how i have to move line now to moved position.
please kindly help me regarding this..
Thanks in advance..
modified on Tuesday, February 17, 2009 10:18 AM
|
|
|
|
|
If slider range has been set from 0 to 100 and SetPos returns 50, you know that it is 50%.
So the position of the tic is at (283 - 86) / 2.
Now you can do a MoveTo and LineTo from X1 which is ((283 - 86) / 2, bottom of slider1) to X2 which is at ((283 - 86) / 2, top of slider 2).
«_Superman_»
|
|
|
|
|
Hi Superman,
I have written the code like this, but still it's not working
while (slide_pos <= 100)
{
m_pDlg->m_slider_bar1.GetWindowRect(&rect1);
m_pDlg->m_slider_bar2.GetWindowRect(&rect2);
int pos = m_pDlg->m_slider_bar1.GetPos();
m_pDlg->x1 = ((rect1.left-rect1.top)/100);
m_pDlg->y1 = rect1.bottom;
m_pDlg->x1 = ((rect1.left-rect1.top)/100);
m_pDlg->y2 = rect2.top;
m_pDlg->m_slider_bar1.SetPos(slide_pos);
m_pDlg->m_slider_bar2.SetPos(slide_pos);
slide_pos = slide_pos + 5;
m_pDlg->InvalidateRect(NULL);
Sleep(1000);
}
rect1 values are :- top=86,bottom=110,left=283,right=565
rect2 values are :- top=259,bottom=283,left=283, right=565.
Can you please look into the code what i have written and let me know where i did wrong..?
modified on Tuesday, February 17, 2009 10:18 AM
|
|
|
|
|
It looks like I have mis-interpreted your question.
Let me try and get it right.
You have 2 sliders.
When one of the slider is moved you want the other one also to move along.
Is that what you need?
«_Superman_»
|
|
|
|
|
Hi,
Yes that is only the part of my requirement. I have two horizontal sliders on my dialog. Now i want to create one verical line in between the two sliders.
Whenever i have clicked on Start button then slider tics will get moved and incremented by 5, i am able to move two slider tics at the same time.
but now what i want is to move line along with the tics. I am not able the slider position where it is exactly moved in terms of pixels.
modified on Tuesday, February 17, 2009 10:29 AM
|
|
|
|
|
You can get the (x1, y1) and (x2, y2) positions for drawing the line using the following code
m_slider1.GetThumbRect(&rect1);
m_slider2.GetThumbRect(&rect2);
m_slider1.ClientToScreen(&rect1);
m_slider2.ClientToScreen(&rect2);
ScreenToClient(&rect1);
ScreenToClient(&rect2);
<span style="color:blue">int</span> x1 = rect1.left + ((rect1.right - rect1.left) / 2);
<span style="color:blue">int</span> y1 = rect1.bottom;
<span style="color:blue">int</span> x2 = x1;
<span style="color:blue">int</span> y2 = rect2.top;
Then you can draw the line using the following code
CDC* pDC = GetDC();
CPen pen(PS_SOLID, 1, RGB(0, 0, 0));
pDC->SelectObject(&pen);
pDC->MoveTo(x1, y1);
pDC->LineTo(x2, y2);
ReleaseDC(pDC);
You may need to erase the previously drawn line.
For that you will need to store the previous line coordinates and draw over it using the same color of the dialog.
«_Superman_»
|
|
|
|
|
Hi Superman,
Thanks for your effort on this..I am able to move slider position correctly, but not able to move along with the sliders, below i am copying my code snippet, please review it and let me know where i am doing wrong..?
Below code i have written in OnStart funciton():-
int slider_pos = 5;
while(slider_pos <= 50)
{
m_slider1.GetThumbRect(&rect1);
m_slider2.GetThumbRect(&rect2);
m_slider1.ClientToScreen(&rect1);
m_slider2.ClientToScreen(&rect2);
ScreenToClient(&rect1);
ScreenToClient(&rect2);
m_slider1.SetPos(slider_pos);
m_slider2.SetPos(slider_pos);
int x1 = rect1.left + ((rect1.right - rect1.left) / 2);
int y1 = rect1.bottom;
int x2 = x1;
int y2 = rect2.top;
slider_pos += 5;
InvalidateRect(rect1,FALSE);
InvalidateRect(rect2,FALSE);
Sleep(1000);
}
Below i have written in OnPaint()
CDC* pDC = GetDC();
pDC->MoveTo(old_x1,old_y1);
pDC->LineTo(old_x2,old_y2);
pDC->MoveTo(x1,y1);
pDC->LineTo(x2,y2);
old_x1 = x1;
old_y1 = y1;
old_x2 = x2;
old_y2 = y2;
Please help me regarding this..?
Thanks in advance..
|
|
|
|
|
You are using x1, y1, x2 and y2 in 2 functions.
I'm assuming you're creating the variables as member variables.
If so remove the int keyword from within the while loop.
Also, in OnPaint you must call BeginPaint instead of GetDC .
And instead of 2 InvalidateRect calls, do a single Invalidate call.
«_Superman_»
|
|
|
|
|
Hi,
I made these changes,
PAINTSTRUCT ps;
CDC* paintDC = BeginPaint(&ps);
//paintDC->MoveTo(old_x1,old_y1);
//paintDC->LineTo(old_x2,old_y2);
paintDC->MoveTo(x1,y1);
paintDC->LineTo(x2,y2);
old_x1 = x1;
old_y1 = y1;
old_x2 = x2;
old_y2 = y2;
EndPaint(&ps);
but line is displaying at last slider position, that to in wrong pixels..
can you please tell me where i am doing wrong..?
Thnaks in advance..
|
|
|
|
|
Hi
Can you please kindly help me on this ASAP, as it is very urgent requirement for me..
|
|
|
|
|
Hi all....as a part of my undergraduate project, i've to design a protocol for streaming audio to another system in a LAN...that protocol should be a layer 2 protocol...can anyone tel me how to implement this and where can i get sample protocol source code and stuffs???? thanks in advance...
|
|
|
|
|
Start on yoursefl, make some research on google and once you are stuck on a specific point, come back and ask a specific question. BTW, read the "How to get an answer to your question" post on top of this forum.
|
|
|
|
|
Hi guys,
I have a frustrating issue that has just cropped up about a week ago.
I have a piece of code which downloads a file via HTTP and saves it to disk.
This code has been working perfectly for the last year on a server, now all of a sudden the call to CHttpFile->Read throws an
exception "Not enough storage is available to process this command".
The server has more than enough memory available (machine has 4gig, of which roughly 1gig is being used at any given time).
It has 12 gig hd space free, drive quota is turned off, and the page file is set to 3 gig min, 4 gig max.
Even straight after a restart, the code still throws the exception.
The file size over the last year has grown from 40meg to 65meg, and that same piece of code is able to download a small 1meg file on the server no problem.
The only bit of advice i have been able to google is that of increasing the IRPStack size, which aparently should fix issues such as this, but unfortunately this does not appear to fix my issue.
If any of you have had any other similar issue, and know of a solution to this problem, please let me know!
Thanks.
|
|
|
|
|