|
OK, if you want to roll your own gradient rect, this formula should work
(((r2 - r1) / (rectheight - 1)) * currentrow) + r1 = rdest
(((g2 - g1) / (rectheight - 1)) * currentrow) + g1 = gdest
(((b2 - b1) / (rectheight - 1)) * currentrow) + b1 = bdest
where
r,g,b == red,green,blue components
Desired Start row color == RGB(r1,g1,b1)
Desired End row color == RGB(r2,g2,b2)
currentrow == current row of rect being drawn (0-based)
RGB(rdest,gdest,bdest) is the resulting color for the currentrow
Note this requires floating point so it will be slower than the standard integer formula.
The example is for vertical gradient - it would work for columns as well (horizontal gradient).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
How to get the Dialog handle of Dialog-based application?
Best Regards,
Suman
|
|
|
|
|
use GetSafeHwnd()
Manish Rastogi
|
|
|
|
|
Hi Manish,
Thanks for the help!!
Best Regards,
Suman
|
|
|
|
|
|
Hi, I want to find the format of a wav file. I use the MediaDetector interface like this:
CoCreateInstance(CLSID_MediaDet,NULL,CLSCTX_INPROC_SERVER,IID_IMediaDet,(void**) &pIMediaDet);
I have included dshow.h and linked to strmiids.lib but I get these link errors:
AudioController.obj : error LNK2001: unresolved external symbol _CLSID_MediaDet
AudioController.obj : error LNK2001: unresolved external symbol _IID_IMediaDet
Any help would be appreciated.
Thanks
Ratna
|
|
|
|
|
#include <Qedit.h>
"This header file is not compatible with Microsoft® Direct3D® headers later than version 7."
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
I am a beginner in MFC. Here is my problem :
I have a MDI application, when I display one image on a child frame, the image disappear if I move(resize or minimize) the frame. I don't really know where the problem comes from.
In my Child frame, I use :
<br />
ON_COMMAND_RANGE(ID_IMAGE1, ID_IMAGE2, OnView)<br />
OnView is like :
<br />
void CChildFrame::OnView(UINT nID)<br />
{<br />
CBitmap bmp1, bmp2;<br />
CClientDC dc1(this), dc2(this);<br />
CDC bmDC1, bmDC2;<br />
BITMAP bi1, bi2;<br />
bmp1.LoadBitmap(IDB_BITMAP1);<br />
bmp2.LoadBitmap(IDB_BITMAP2);<br />
<br />
bmDC1.CreateCompatibleDC(&dc1);<br />
bmDC2.CreateCompatibleDC(&dc2);<br />
<br />
CBitmap *pOldbmp1 = bmDC1.SelectObject(&bmp1);<br />
CBitmap *pOldbmp2 = bmDC2.SelectObject(&bmp2);<br />
<br />
bmp1.GetBitmap(&bi1);<br />
bmp2.GetBitmap(&bi2);<br />
<br />
<br />
switch( nID )<br />
{<br />
case ID_IMAGE1:<br />
<br />
dc1.BitBlt(0,0,bi1.bmWidth,bi1.bmHeight,&bmDC1,0,0,SRCCOPY);<br />
bmDC1.SelectObject(pOldbmp1); <br />
<br />
break;<br />
<br />
case ID_IMAGE2:<br />
<br />
dc2.BitBlt(0,0,bi2.bmWidth,bi2.bmHeight,&bmDC2,0,0,SRCCOPY);<br />
bmDC2.SelectObject(pOldbmp2);<br />
<br />
break;<br />
}<br />
}<br />
Any help would be very appreciated
|
|
|
|
|
Typically you should be drawing in a view, in a CView::OnDraw() override.
You're drawing in a frame window, which, if there's a view embedded in it, the view window is
covering whatever you draw.
If there's not an embedded view in the frame, then you need to draw your bitmap in response to
WM_PAINT.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
ok thank you, I will try this way.
|
|
|
|
|
Hi all. Im going to try my best to explain what i need here.
I need a function to return true if a certain parameter is entered in, based on the true i need other function to call on this function to make sure its ok to proceed, if false is returned then dont do anything, if true is returned then go ahead and execute. I made a simple prog using a boolean to return true.
<br />
#include <iostream><br />
#include <string><br />
using namespace std;<br />
bool password(const char* pass);<br />
<br />
<br />
string input;<br />
int main(){<br />
cout << "Please enter password: ";<br />
cin >> input;<br />
password(input.c_str());<br />
system("pause");<br />
return 0;<br />
}<br />
<br />
bool password(const char* pass){<br />
string password="stupidpass";<br />
if(password == input){<br />
cout << "Password correct! " << endl;<br />
return true;<br />
}<br />
else<br />
{<br />
cout << "Password incorrect! " << endl;<br />
return false;<br />
}<br />
}<br />
It works perfectly. Now what it is im trying to do is compare the strings from password and the sock buffer. So i tried the following ...
<br />
bool checklogin(const char* login);<br />
<br />
if(servbuff.find(login) != string::npos){<br />
if(servbuff.find(auth) != string::npos){<br />
checklogin(servbuff.c_str());<br />
}<br />
else{<br />
error();<br />
}<br />
}<br />
<br />
bool checklogin(const char* login){ <br />
if(password == servbuff){<br />
cout << "Login correct " << endl;<br />
return true;<br />
}<br />
else{<br />
cout << "Login incorrect " << endl;<br />
return false;<br />
}<br />
}<br />
And it kept saying incorrect, i know that it is because the string isnt matching correctly. What im trying to figure out how would i go about calling the function with the parameter that will send what it needs to match the two strings. If im unclear about something let me know and i'll try to be more specific. Thanx in advance!
|
|
|
|
|
If you step through with the debugger this should be easy to spot. At which line is the check
failing? What are the values of the strings at that point?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi All;
I am trying to create a function that takes two
struct tm's and get the bigger of them by difftime.
i am trying the following:
time_t tMyTime, tZeroTime;
struct tm ZeroYear ;
struct tm myTime;
struct tm* pZeroYear = &ZeroYear;
struct tm* pMyTime = &myTime;
ZeroYear.tm_year = 1970;
ZeroYear.tm_mon = 1;
ZeroYear.tm_mday = 1;
ZeroYear.tm_hour = 0;
ZeroYear.tm_min = 0;
ZeroYear.tm_sec = 0;
myTime.tm_year = 2007;
myTime.tm_mon = 7;
myTime.tm_mday = 23;
myTime.tm_hour = 21;
myTime.tm_min = 51;
myTime.tm_sec = 59;
tMyTime = mktime(pMyTime); // ERROR return -1
tZeroTime = mktime(pZeroYear); // ERROR return -1
double testTime = difftime(tMyTime,tZeroTime);
cout<<" testTime is : "<< testTime; // 0 is printed
I know i can check each value one by one but is there a better option?
as you must have noticed i am new to this stuff and it does not work...
thanks alot
Beri
|
|
|
|
|
beriho wrote: tMyTime = mktime(pMyTime); // ERROR return -1
tZeroTime = mktime(pZeroYear); // ERROR return -1
mktime() handles dates in any time zone from midnight, January 1, 1970, to January 18, 19:14:07, 2038. You are trying to handle dates in the years 3870 and 3907, respectively.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
thanks for your reply;
so i need to get from user like this if i want to check year 2007?
CurrentTime.tm_year = 107;
myTime.tm_year = 107;
thanks again
Beri
-- modified at 17:24 Monday 23rd July, 2007
|
|
|
|
|
beriho wrote: so i need to get from user like this if i want to check year 2007?
Yes, since the years are from 1900.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
take a look at the time( ) C Runtime api and work with this, the value is in seconds so you can easily take the differences
look at the "Time Management" section in MSDN, you can convert from _time to /from struct tm
Yours Truly, The One and Only!
|
|
|
|
|
hi all,
can anyone tell how to use sockets to retrieve data from url page
like retrieving yahoo multiple stock quotes .
Thank u all
prem
|
|
|
|
|
create a socket
open a connection
send the request
receive the response
shutdown the socket
close the socket
process the response data
|
|
|
|
|
|
I could imagine debugging...."It crashes at the 'shutdown the socket' call
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Randor wrote: I didn't know you were a member
Oh dear, i didn't even consider that!
|
|
|
|
|
erase cookies cookie from webbrowser control
how do i erase all the cookies or cookie from my webbrowser control?
|
|
|
|
|
Do you mean the "cookie" files that reside on the HD?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|