|
This probably sounds like an ridiculously simple question but the DirectX 8.0 docs read like stereo intructions:
Once I have created an IDirect3DTexture8 texture in DirectX 8.0, how do I go about setting the color and alpha channel of individual pixels in that texture if I do not want to do so by loading an image file? (Actually, I am loading an image file but it's in a special format so I can't use any of the DirectX LoadImage functions.)
|
|
|
|
|
Calling SHGetSpecialFolderPath with CSIDL_WINDOWS and with CSIDL_DESKTOPDIRECTORY works fine in Windows XP, but in Windows 98 (SP1, IE6 SP1) CSIDL_WINDOWS doesn't work. Why is that? Is there a better way to get the user's Windows directory?
Thanks!
|
|
|
|
|
IGx89 wrote:
Calling SHGetSpecialFolderPath with CSIDL_WINDOWS and with CSIDL_DESKTOPDIRECTORY works fine in Windows XP, but in Windows 98 (SP1, IE6 SP1) CSIDL_WINDOWS doesn't work. Why is that?
According to MSDN, usage of CSIDL_WINDOWS requires Shell32.dll v5.0, i.e. at least Windows 2000 or Windows Millenium.
IGx89 wrote:
Is there a better way to get the user's Windows directory?
Try following:
TCHAR szWinDir[MAX_PATH+1] = {0};
GetEnvironmentVariable(_T("windir"), szWinDir, MAX_PATH);
Regards
Thomas
Sonork id: 100.10453 Thömmi
Disclaimer: Because of heavy processing requirements, we are currently using some of your unused brain capacity for backup processing. Please ignore any hallucinations, voices or unusual dreams you may experience. Please avoid concentration-intensive tasks until further notice. Thank you.
|
|
|
|
|
IGx89 wrote:
Is there a better way to get the user's Windows directory?
How about the standard, old GetWindowsDirectory(...) function?
BTW: I do not believe that Win9x supported different/shared Windows/System directories a'la Win2K or later.
Peace!
-=- James (Sonork:100.21837)
[Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!] [Get Check Favorites 1.5 Now!]
|
|
|
|
|
Hehe, that function just might work
|
|
|
|
|
hi everyone,
i'm working on a sdi application with window's explorer style(i.e. a
sdi application with a vertical splitter, dividing the windows into 2
panes, left and right pane).
i added a command, named 'add info', to the main menu and added the event handler to 'add info'. the coding of the event handler of 'add info'
command is done in left pane class. what 'add info' command do is creating a dialog that collects inputs from users then store these user inputs into a database. i modified the contructor of the dialog for 'add info' to accept a database object pointer(get past from the left pane class, when the dialog object is created).
when i start the program, if the windows focus in on left pane, i was able to run 'add info' command, display the dialog, save the inputs from the dialog and store in the database without any problem.
the problem occurs when my window focus is on right pane, if i run
'add info', i get error 'Unhandled exception at 0x005832ba in cat.exe: 0xC0000005: Access violation reading location 0x61636f4c.'
and the debugger points out that the program crashes at line 44 in objcore.cpp, within the function iskindof(.....)..
here is the function..
BOOL CObject::IsKindOf(const CRuntimeClass* pClass) const
{
ASSERT(this != NULL);
// it better be in valid memory, at least for CObject size
ASSERT(AfxIsValidAddress(this, sizeof(CObject)));
// simple SI case
CRuntimeClass* pClassThis = GetRuntimeClass();
return pClassThis->IsDerivedFrom(pClass);
}
i have no idea how to fix this bug. can someone help me out? thx in advance..
|
|
|
|
|
Did you try checking whether the db pointer you are passing to the dialog is valid.
Cheers
Kannan
|
|
|
|
|
how do you check whether the db pointer that i'm passing to the dialog is valid or not? because the dialog works perfectly when i had my window focus on the left pane, which is where the event handler was coded from, but when my window focus is on the right pane, my application crashed.. i too was suspecting about the db pointer, but i don't know how to fix it.. any suggestions? thx in advance.
|
|
|
|
|
When it is crashing in some windows function, you simply have to look into the call stack window to see from where it was called. Do this recursivly until you end into a class or function you know (either having written it or having used it in your code). Then look in there what went wrong .
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
How do I programmtically associate a file type with an application in Windows ?
|
|
|
|
|
Sameers wrote a article on just this. I can't say I've tried it, although I plan to when I find some (quiet alot of) spare time. Ahh... here it is...[^]
If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
How to change the title on the dialog title bar in a window?
It was created in MFC with the title bar "abc" and I want to change it to "ghj". How can I do it?
|
|
|
|
|
pDlg->SetWindowText("ghj");
Pavel
Sonork 100.15206
|
|
|
|
|
Thank you.
|
|
|
|
|
Hello,
I am having problems with CAsyncSocket.. The errors occurs when I accept a socket.. I then have a function that resolves the IP address of the socket.. It then compairs the IP address with all of the IP address in an array.. then it returns a CString value of the IP address. After that I try to send data to the socket and I receive the following error..
The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
(Press Retry to Debug the Application)
Here is my Resolve function.. (It's returning the correct value)..
CString CMainFrame::OnCompareAddress(CMySocket* pSocket)
{
CString strAddress,strListAddress, strDns, strName;
unsigned int iPort;
pSocket->GetPeerName(strAddress, iPort);
int iCount = m_array.GetSize();
while(iCount > 0)
{
ProcessMessages();
sfriend pFriend;
pFriend = m_array.GetAt(iCount-1);
CString strDns = pFriend.strDns;
hostent *pHost = gethostbyname(strDns);
if ( pHost != 0 )
{
sockaddr_in addr;
memset( &addr, 0, sizeof(addr) );
addr.sin_family = AF_INET;
memcpy( &addr.sin_addr, pHost->h_addr, pHost->h_length );
strListAddress = inet_ntoa(addr.sin_addr);
}
else
iCount = 0;
if(!strAddress.CompareNoCase(strListAddress))
{
strName = strDns;
iCount = 0;
}
else
iCount --;
}
if(!strName.IsEmpty())
return strName;
else
return strAddress;
}
My accept function..
void CMainFrame::OnAccept()
{
CMySocket* pSocket = new CMySocket();
pSocket->SetParent(this);
if (!m_sListen.Accept(*pSocket))
delete pSocket;
else
{
m_pConnectionList.AddTail(pSocket);
CString strName = OnCompareAddress(pSocket);
int nFound = 0;
int iCount = m_array.GetSize();
while(iCount > 0)
{
sfriend pFriend;
pFriend = m_array.GetAt(iCount-1);
CString strDns = pFriend.strDns;
if(!strDns.CompareNoCase(strName))
{
nFound = 1;
iCount = 0;
}
else
iCount --;
}
if(nFound = 0 )
{
CString strMessage;
strMessage = "(NOT_IN_LIST): ";
int iLen = strMessage.GetLength();
pSocket->Send((LPCSTR)strMessage,iLen);
OnCloseConnection(pSocket);
}
else
OnSendMyStatus(pSocket);
}
}
Any Ideas??
Rob
|
|
|
|
|
No. I recommend Winsock Win32 functions because you have more control in program design and implementation. You have no idea what the MFC Winsock class does.
Kuphryn
|
|
|
|
|
Im having a problem with timing a function. Here's how Im doing it now:
<br />
const double LOOP_MAX = 999;<br />
LARGE_INTEGER tCS,tCE;<br />
double Ang = 0,Res;<br />
<br />
QueryPerformanceCounter(&tCS);<br />
<br />
while (Ang++ < LOOP_MAX)<br />
CMObj::Function(Ang, Res);<br />
<br />
QueryPerformanceCounter(&tCE);<br />
<br />
tCS.QuadPart = tCE.QuadPart- tCS.QuadPart;<br />
QueryPerformanceFrequency(&tCE);<br />
<br />
double t = (double)tCS.QuadPart / tCE.QuadPart;<br />
<br />
double ps = LOOP_MAX / t;<br />
When I run the LOOP_MAX at 1 - 999, I get about 393,000 calls per second. But as I raise LOOP_MAX from there my calls per second drop (At 99,999 I get only 85,022). Is there something wrong with the way Im calculating this, or is there a reason why my call time would drop?
|
|
|
|
|
Try something like this
I just found this code in my mail, I havent used this code, but my friend told me it just worked fine for him.
<br />
#include < iostream ><br />
#include < windows.h ><br />
<br />
int DoTest()<br />
{<br />
int i;<br />
i = 42;<br />
return i*15;<br />
}<br />
<br />
int DummyTest()<br />
{<br />
return 0;<br />
}<br />
<br />
int main()<br />
{<br />
__int64 i64Start;<br />
__int64 i64End;<br />
__int64 i64Overhead;<br />
__int64 i64Frequency;<br />
__int64 i64Elapsed;<br />
<br />
const int iIterations = 100000;<br />
int result;<br />
<br />
QueryPerformanceCounter((LARGE_INTEGER*)&i64Start);<br />
for (int i = 0; i < iIterations; ++i)<br />
result = DummyTest();<br />
QueryPerformanceCounter((LARGE_INTEGER*)&i64End);<br />
<br />
i64Overhead = i64End - i64Start;<br />
<br />
QueryPerformanceCounter((LARGE_INTEGER*)&i64Start);<br />
for (i = 0; i < iIterations; ++i)<br />
result = DoTest();<br />
QueryPerformanceCounter((LARGE_INTEGER*)&i64End);<br />
<br />
i64Elapsed = (i64End - i64Start) - i64Overhead;<br />
<br />
QueryPerformanceFrequency((LARGE_INTEGER*)&i64Frequency);<br />
<br />
std::cout << "Time elapsed was: " << (double)i64Elapsed /<br />
(double)i64Frequency << " seconds" << std::endl;<br />
<br />
return 0;<br />
}<br />
Cheers
Kannan
|
|
|
|
|
I need a non-MFC method for converting the contents of a FILETIME struct into an integer (or double) representation that can be used for date/time comparisons.
Anybody got anything like that?
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
Well, I was gonna suggest CTime, but...
John Simmons / outlaw programmer wrote:
I need a non-MFC method
Actually, I think the only reason I even use MFC is for things like CTime and CString.
Anyway, take a look @ this[^] if you haven't already. It works with a SYSTEMTIME structure, but if you get the number of days or hours out of the 100-nanosecond intervals of the FILETIME, (like with an int64 or LONGLONG) you may be able to use some of the stuff in that article to add the time onto January 1, 1601 or whenever the FILETIME date thing starts (i didn't see any MFC stuff in there whilst quickly passing through)...
P.S. Sorry if that is of absolutly no help
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
From MSDN:
"Copy the resulting FILETIME structure to a ULARGE_INTEGER structure. Use normal 64-bit arithmetic on the ULARGE_INTEGER value."
Or you could convert it using FileTimeToSystemTime() and then populate the old struct tm.
J
May the bear never have cause to eat you.
|
|
|
|
|
Is the CompareFileTime() API insufficient for your needs? If you need a single number (not a struct) you can convert a FILETIME to a quadword:
FILETIME ft;
DWORDLONG qwTime;
qwTime = DWORDLONG(ft.dwHighDateTime) << 32 | ft.dwLowDateTime;
--Mike--
"Adventure. Excitement. A Jedi craves not these things."
-- Silent Bob
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Ok I've changed things around and it is as good as working apart from.....
1. If the queue has been emptied (after input) and I then try to view the queue I'd like a message no data in queue, have tried various methods to no avail, at the moment it just returns to main menu, as it runs void show and shows nothing as it should, but I want that message!!
2. My queue size isn't owrking i can have a queue of 3 and it will allow a 4th to be entered, yet NOT store this (GOOD), but would be better to not allow the 4th to be entered.
Thanks in advance.
Ian
2.
#include<iostream.h><br />
class Queue<br />
{<br />
private:<br />
int *input;<br />
int Array_Size;<br />
int first;
int last;
public:<br />
Queue(int);<br />
~Queue();<br />
void push(int);<br />
int pop();<br />
void show();<br />
};<br />
<br />
Queue::Queue(int data)<br />
{<br />
Array_Size=data + 1;<br />
input = new int[Array_Size];<br />
first=Array_Size;<br />
last=0;<br />
}<br />
<br />
Queue::~Queue()<br />
{<br />
delete input;
}<br />
void Queue::push(int info)<br />
{<br />
if ( first == last + 1 ) <br />
{<br />
cout<<"Queue is full\n";<br />
return;<br />
}<br />
<br />
input[last++] = info;
last %= Array_Size;
}<br />
int Queue::pop()<br />
{<br />
if ( first % Array_Size == last ) <br />
{<br />
cout<<"\n\nNo students waiting in the queue\n";<br />
return -1;<br />
}<br />
<br />
first %= Array_Size;
return input[first++];
}<br />
<br />
void Queue::show()<br />
{<br />
int it = first;<br />
while ( it != last )<br />
{<br />
it %= Array_Size;<br />
cout<<"|"; cout<<input[it++]; cout<<"| ";<br />
}<br />
<br />
}<br />
<br />
int menu()<br />
{<br />
int choice = 0;<br />
cout<<"\n\n\t\t**MAIN MENU**";<br />
cout<<"\n\n\t1\tStudent number to join the queue";<br />
cout<<"\n\t2\tStudent seen (Remove from queue)";<br />
cout<<"\n\t3\tView the students in the queue";<br />
cout<<"\n\t4\tEXIT";<br />
cout<<"\n\n\tPlease enter your choice : ";<br />
cin>>choice;<br />
return choice;<br />
}<br />
<br />
int main()<br />
{<br />
int StudentID = 0;
int qsize;<br />
int option;<br />
int set=0;<br />
<br />
cout<<"\n\tPlease enter the length of the Queue : ";<br />
cin>>qsize;<br />
set = qsize;<br />
while (qsize<1 ||qsize>15)<br />
{ <br />
cout<<"\nNot a valid queue size, must be between 1 and 15";<br />
cout<<"\nTry again: ";<br />
cin>>qsize;<br />
}<br />
Queue q(qsize);<br />
do<br />
{<br />
option = menu();<br />
switch(option)<br />
{<br />
case 1:<br />
cout<<"\n\t* * Valid student numbers between 1 and 500 only * *\n";<br />
cout<<"\nEnter the student number : ";<br />
cin>>StudentID;<br />
while (StudentID < 1 || StudentID > 500)<br />
{<br />
cout<<"Invalid entry try again: ";<br />
cin>>StudentID;<br />
}<br />
q.push(StudentID);<br />
cout<<"\nStudent "<<StudentID<<" has been inserted into queue.";<br />
break;<br />
case 2:<br />
<br />
if ( ( StudentID = q.pop() ) != -1 )<br />
cout<<"\nStudent "<<StudentID<<" has been deleted from the queue.";<br />
break;<br />
case 3:<br />
<br />
if (StudentID==0||StudentID==-1)<br />
{<br />
cout<<"\nNo students entered yet!";<br />
break;<br />
}<br />
<br />
q.show();<br />
break;<br />
case 4:<br />
cout<<"\n** GOODBYE **\n";<br />
break;<br />
default:
cout<<"\nIncorrect entry, try again with 1,2,3 or 4.";<br />
}<br />
}<br />
while (option!=4);<br />
}
|
|
|
|
|
Does your queue need to be a fixed size ? The other way to do it is a linked list, which is where you create a series of items that each contain the data you want, and a pointer to the next item, and possibly the previous also.
ian_ok wrote:
delete input; // Clean up
This does not work. To delete an array you need to do this:
delete [] input;
ian_ok wrote:
first=Array_Size;
last=0;
What are these for ? If you have an array, you can keep an index of how many items you have, and access items using either array notation ( input[pos] ), or pointer arithmetic ( *(input+pos) ).
I see you're using array notation.
ian_ok wrote:
first %= Array_Size; // Wrap the queue
return input[first++]; // Remove
I don't get this - how does this remove items from the queue ? That is, how does it reclaim the memory and make room in the queue ? If you want to use an array as your storage, you should use memcpy to move all the existing values down so there is room created at the end.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Hi everyone!
I need to resize all the controls in a CFormView class on WM_SIZE message.
I tried to resize each control seperately but it didn't worked.
Also tried the code from OnInitialUpdate():
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
but it does not resizes the controls...
Any solutions of the problem?
Thanks in advance!
Gogou
|
|
|
|