|
I have this class
class A (definition)
{
...
private:
TCHAR _sWord[16];
public:
void Word( TCHAR word[16] );
TCHAR* Word( void );
}
class A (implementation)
{
void CWordData::Word( TCHAR word[16] )
{
this->_sWord = word;
}
TCHAR* CWordData::Word( void )
{
return _sWord;
}
}
The problem I want _sWord defined to [16]. But I cant figure out how ref it inside the methods.
Please help me with this ignorant ?
Nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Instead of this
Ista wrote:
void CWordData::Word( TCHAR word[16] )
{
this->_sWord = word;
}
use this
_tcscpy(this->_sWord , word);
you cannot copy two string using = operator.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
I knew it was ignorant.
thanks.
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Hey, so I have been trying to load several bitmaps into a program I am writing.
I am using DirectDraw to display the graphics of this program. I want to load a bitmap from a .bmp file, then use the IDirectDrawSurface3::Blt method to display it.
First, according to a tutorial I am doing, I tried to write my own function to load a bitmap.
typedef struct BmpFile <br />
{<br />
BITMAPFILEHEADER fileHeader;<br />
BITMAPINFOHEADER infoHeader;<br />
PALETTEENTRY pallete[256];<br />
UCHAR *buffer;<br />
} BmpFile, *BmpFilePtr;<br />
<br />
<br />
int GraphicsEngine::LoadBitmapFile(BmpFilePtr bmp, char *fileName)<br />
{<br />
HANDLE fileHandle = NULL;<br />
<br />
if ((fileHandle = CreateFile(fileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)<br />
return 401;
<br />
if (!(ReadFile(fileHandle, &bmp->fileHeader, sizeof(BITMAPFILEHEADER), NULL, NULL)))<br />
{<br />
CloseHandle(fileHandle);<br />
return GetLastError();<br />
}<br />
<br />
Whenever I run this, CreateFile appears to successfully load the file, and fileHandle is set to a value. Then the function ReadFile fails. GetLastError returns 998 (which is the code for: Invalid access to memory location. ERROR_NOACCESS).
I was pretty stumped by this, so I looked around a while, and I found a function called LoadImage().
I looked it up, and came up with the code
HBITMAP hbmp = (HBITMAP)LoadImage(NULL, fileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
But I have a problem with this, too ; I have no idea how to get the BMP data out of the handle... I'm not using MFC, so I can't use CBitmap. Is there any other way of getting the data, so that I can put it on an IDirectDrawSurface and display it using Blt?
If anyone can help me solve either method of loading a bitmap, or if that's not feasible, instruct me in the use of a third method, I would be greatly appreciative.
Thanks for your help, everyone.
-----
I am a programar
I am a programer
I am a programor
I write code.
|
|
|
|
|
Why you want to use adirectx versionthats at least 5 years old I have no idea. but...
this is an example
http://www.codeproject.com/directx/basicdd.asp[^]
By the way you can use the MFC libraries in a win32 app. Its much easier to show a bitmap and init'ing directx.
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Cool, thanks a lot.
(And regarding why I am using an old version of direct X and why I am not using MFC:
After I learned C++, I was getting pretty bored of console apps, and wanted to learn how to windows apps. I tried from various tutorials for a while, but as I am fairly new to this, I was unable to make any progress.
Then I found an old book, called "Tricks of the Windows Game Programming Gurus", by Andre LaMothe. Its outdated, sure, but the gradient was perfect for me, and it was all I had at hand.)
|
|
|
|
|
get beginning direct3d first. its by lamothe.
its a good start.
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
If I use the default "Save", "Open", or "Save As" in the Menu of an Single Document Interface, my program is unable to open files internally. The files I open internally and those I use the above menu items on are not the same, and are not related.
PLEASE HELP! How to overcome this problem??
|
|
|
|
|
Use full path names when specifying your files. The default file dialogs change the current directory.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
The files I use internally are in directories that are in the same location as the program. IF someone moves the whole thing, how can I get the file path? I used "Directory1\file.txt" before, but how to get the whole path?
Thank you very much. I will try it manually to see if it will work. Thanks!
Kem
|
|
|
|
|
You can use GetModuleFileName() to get the path to the .exe. You can use that path to build your file paths.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Dear Sir,
Thank you VERY MUCH! It worked, and my program seems to be running ok. I really appreciate the help. If you're ever in the Philly area, let me know. I owe you a drink!
Kem
|
|
|
|
|
Rihannsu wrote:
If you're ever in the Philly area, let me know. I owe you a drink!
Just send cash;P
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
I'm working on a program that reads a small text file (from AppPath) every x seconds, and is always running on the computer. Since most computers are always on, should I keep that x value as low as possible to reduce wear on the hard drive (and maximize laptop battery life), or is that not really a problem? I currently have x set at 5 seconds, and could go as long as 60 seconds.
|
|
|
|
|
If you are waiting for the file to change some how you may be better off using this[^] approach.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Doh, can't believe I didn't think of that . Thanks!
I actually decide to use FindFirstChangeNotification, because it supports 98/ME.
|
|
|
|
|
People that use power management (eg laptops) will not be happy with that method, because the constant disk access will prevent the computer from going into power-saving mode (stand-by/hibernate).
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
My problem is that I have to read the content of a web page which is dynamic (written in PHP), and the content is always different. I read the content using the following code :
<br />
void CHS_VCDlg::Onread() <br />
{<br />
CString URL = "http://www.eed.usv.ro/~pentiuc/hs2005/index.php";<br />
CInternetSession session;<br />
m_Result += "Trying " + URL + "\r\n";<br />
UpdateData(FALSE);<br />
CInternetFile* file = NULL;<br />
try<br />
{<br />
file = (CInternetFile*) session.OpenURL(URL);<br />
}<br />
catch (CInternetException* pEx)<br />
{<br />
file = NULL;<br />
pEx->Delete();<br />
}<br />
if (file)<br />
{<br />
m_Result += "Connection established. \r\n";<br />
CString line;<br />
for (int i=0; i < 20 && file->ReadString(line); i++)<br />
{<br />
m_Result += line + "\r\n";<br />
}<br />
file->Close();<br />
delete file;<br />
}<br />
else<br />
{<br />
m_Result += "No server found there. \r\n";<br />
}<br />
m_Result += "------------------------\r\n";<br />
UpdateData(FALSE);<br />
}<br />
It works well, but the problem is that I have to clear the cache and the cookies all the time from Internet Explorer.
I want to know if there a way to clear the cache and the cookies by code in order to read the new content of the page every time I call this function??
Croitoriu Andrei
croi2001@yahoo.com
|
|
|
|
|
|
I tried ti use DeleteUrlCacheEntry() and even found a more complete function:
<br />
#include <wininet.h><br />
BOOL DelTempFiles()<br />
{<br />
BOOL bResult = FALSE;<br />
BOOL bDone = FALSE;<br />
LPINTERNET_CACHE_ENTRY_INFO lpCacheEntry = NULL;<br />
<br />
DWORD dwTrySize, dwEntrySize = 4096;
HANDLE hCacheDir = NULL;<br />
DWORD dwError = ERROR_INSUFFICIENT_BUFFER;<br />
<br />
do<br />
{<br />
switch (dwError)<br />
{<br />
case ERROR_INSUFFICIENT_BUFFER:<br />
delete [] lpCacheEntry;<br />
lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize];<br />
lpCacheEntry->dwStructSize = dwEntrySize;<br />
dwTrySize = dwEntrySize;<br />
BOOL bSuccess;<br />
if (hCacheDir == NULL)<br />
<br />
bSuccess = (hCacheDir<br />
= FindFirstUrlCacheEntry(NULL, lpCacheEntry,<br />
&dwTrySize)) != NULL;<br />
else<br />
bSuccess = FindNextUrlCacheEntry(hCacheDir, lpCacheEntry, &dwTrySize);<br />
<br />
if (bSuccess)<br />
dwError = ERROR_SUCCESS;<br />
else<br />
{<br />
dwError = GetLastError();<br />
dwEntrySize = dwTrySize;
}<br />
break;<br />
<br />
case ERROR_NO_MORE_ITEMS:<br />
bDone = TRUE;<br />
bResult = TRUE;<br />
break;<br />
<br />
case ERROR_SUCCESS:<br />
<br />
if (!(lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY))<br />
<br />
DeleteUrlCacheEntry(lpCacheEntry->lpszSourceUrlName);<br />
<br />
dwTrySize = dwEntrySize;<br />
if (FindNextUrlCacheEntry(hCacheDir, lpCacheEntry, &dwTrySize))<br />
dwError = ERROR_SUCCESS;<br />
<br />
else<br />
{<br />
dwError = GetLastError();<br />
dwEntrySize = dwTrySize;
}<br />
break;<br />
<br />
default:<br />
bDone = TRUE;<br />
break;<br />
}<br />
<br />
if (bDone)<br />
{<br />
delete [] lpCacheEntry;<br />
if (hCacheDir)<br />
FindCloseUrlCache(hCacheDir);<br />
<br />
}<br />
} while (!bDone);<br />
return bResult;<br />
}<br />
I tried to use this function but I get the following errors:
<br />
--------------------Configuration: HS_VC - Win32 Debug--------------------<br />
Compiling...<br />
HS_VCDlg.cpp<br />
Linking...<br />
HS_VCDlg.obj : error LNK2001: unresolved external symbol __imp__FindCloseUrlCache@4<br />
HS_VCDlg.obj : error LNK2001: unresolved external symbol __imp__DeleteUrlCacheEntry@4<br />
HS_VCDlg.obj : error LNK2001: unresolved external symbol __imp__FindNextUrlCacheEntryA@12<br />
HS_VCDlg.obj : error LNK2001: unresolved external symbol __imp__FindFirstUrlCacheEntryA@12<br />
Debug/HS_VC.exe : fatal error LNK1120: 4 unresolved externals<br />
Error executing link.exe.<br />
<br />
HS_VC.exe - 5 error(s), 0 warning(s)<br />
<br />
Can anyone tell me why do I get those errors ? What is wrong... where is my mistake?
Please help me...
Croitoriu Andrei
croi2001@yahoo.com
|
|
|
|
|
|
I am trying clear a Cstring variable null. I tried NULL, didnt work.
I tried '\0' , worked but i can't append anything to the cstring.
I just need to make cstring variable blank(or clear it) and when user presses the number buttons, they are appended to the cstring variable.
Thanks in advance.
-hithesh
|
|
|
|
|
CString str;
str = _T("");
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Thanks. I just used quotes and it worked.
-hithesh
|
|
|
|
|