|
Hallo sande,
I had the problem, that I used a COleDateTime-variable and was not able to format it like "MM-yyyy" or anything else. So I was suggested to use a CDateTimeCtrl, as you do, and to use the command
m_begin.SetFormat("MM-yyyy");
in the OnInitDialog().
Worked fine, but I was not able anymore, to get the entered values back where I wanted - thats been after
if (dialog.DoModal() == IDOK)
{
......
So I had to declare a variabe like this
public:
COleDateTime p_begin;
in my dialog and in my dialog.OnOk() I had to use
m_begin.GetTime(p_begin);
This works fine (with the only fault, that I don't know how to give the CDateTimeCtrl special starting-values) and I can use fuctions like
year.Format("%i", dialog.p_begin.GetYear());
after the OnOK().
Good luck, Gerard
-- modified at 15:17 Thursday 22nd June, 2006
|
|
|
|
|
We're using tons of bitmap buttons in our application, and I always wondered how people use the Resource editor to put those buttons and have them well aligned.
Since the Resource editor is working in DLU how do I know that the buttons align ?
Now, I have to do it manually, which seems to be counter-productive; placing one button and put all the rest in reference to that first one.
I know that if I put a Bitmap CStatic and assign it a bitmap, the control will use the size of the bitmap; is there such a thing for buttons ?
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote: We're using tons of bitmap buttons in our application
Maximilien wrote: which seems to be counter-productive
Yes it does. Perhaps a Usability Study and UI Design rework could be considered?
|
|
|
|
|
Are you wanting to know how to use the resource editor, or what guidelines to follow?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
yes and no, I know ( I think ) how to use the resource editor.
My problem now, is only (mostly) with CBitmapButton .
In MSDN, on the CBitmapButton page there is :
To include a bitmap-button control in a dialog box
1. Create one to four bitmap images for the button.
2. Create a dialog template with an owner-draw button positioned where you want the bitmap button. The size of the button in the template does not matter.
Yeah, cool, but heck the position and size are in DLUs not in pixel. I can only approximatly position and size the buttons in resource editor.
for example, I have a series of CBitmapButton buttons with bitmaps that are 40x40 pixels. How can I adjust the positions of each buttons ?
Or, for example, if I have a simple CButton with the BS_ICON or BS_BITMAP flag enable, I'd like to be able to see the bitmap in the button when designing the dialog.
I don't know if you understand what I'm trying to do ? or achieve ?
I know that the CBitmapButton does not seems to be fully supported, not the in palette of controls in the resource editor; and I can live with the fact that I need to do things manually.
My things are working, but it just seem like I'm doing too much; maybe it's the fact of life when doing UI that is not 100% window lookalike.
Thanks
Max.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote: Yeah, cool, but heck the position and size are in DLUs not in pixel.
Right. I suppose exceptions to the rule exist, but I've never had the need to be concerned with pixels. DLUs are portable, pixels are not.
Maximilien wrote: I can only approximatly position and size the buttons in resource editor.
I think all you need to be concerned with is the top and left sides as the control will adjust its width/height accordingly.
Read here for more.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Please come to my forum. I need new people in my forum.
http://cppmasters.iphpbb.com
THX.
-:KNOX:-
|
|
|
|
|
Read #10 here.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
come on knox, you know you're a looser... why linking your forum where the best programming questions are on CP
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
Hi there,
I am basically having trouble acquiring the pointed value of a pointer. Below is the code I am working with.
<code>
int main( void ){
char* RegLocation = "";
char rspath[255];
strcpy(rspath,"");
if(GetRegistryValue(HKEY_LOCAL_MACHINE,"SOFTWARE\\Red Storm Entertainment\\Rogue Spear","InstallationPath",rspath)){
lstrcat(rspath, "\\");
lstrcpy(RegLocation, rspath);
if(retrieveLogFileLocation(RegLocation)){
if(GenerateStats(RegLocation, hOutput)){
}
}
}
return 0;
}
BOOL GetRegistryValue(HKEY key, const char* path, const char* name, char* value)
{
HKEY hKey;
strcpy(value,"");
if (RegOpenKeyEx(key, path, 0, KEY_EXECUTE, &hKey) == ERROR_SUCCESS)
{
char szBuf[MAX_PATH];
DWORD dwLen=MAX_PATH;
if (RegQueryValueEx(hKey, name, NULL, NULL, (unsigned char*) szBuf, &dwLen) == ERROR_SUCCESS)
{
strcpy(value,szBuf);
RegCloseKey(hKey);
return TRUE;
}
RegCloseKey(hKey);
hKey = NULL;
}
return FALSE;
}
bool retrieveLogFileLocation(LPSTR lszRSPath){
char lszValue[255];
char search[255];
lstrcpy(search,lszRSPath);
lstrcpy(lszValue,lszRSPath);
lstrcat(search, "*.log");
WIN32_FIND_DATA wfd;
HANDLE hFind = FindFirstFile(search, &wfd);
if (hFind != INVALID_HANDLE_VALUE) {
do
{
string foo = wfd.cFileName;
if (foo.find("RSResults") != -1)
{
lstrcat(lszValue,wfd.cFileName);
lstrcpy(lszRSPath, lszValue);
FindClose(&wfd);
return TRUE;
}
} while (FindNextFile(hFind, &wfd));
FindClose(&wfd);
}
return FALSE;
}
bool GenerateStats(LPSTR lszLogFile){
HANDLE hLogFile = NULL;
bool pSuccess = FALSE;
cout << "Value pointed is " << lszLogFile << endl;
cout << "Value dereferenced is " << *lszLogFile << endl;
hLogFile = CreateFile(lszLogFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if(hLogFile != INVALID_HANDLE_VALUE){
cout << "Able to create file" << endl;
DWORD dwFileSize, dwRead;
dwFileSize = GetFileSize(hLogFile, NULL);
if(LockFile(hLogFile, 0, 0, dwFileSize, 0))
{
HANDLE hHeapFile;
LPVOID lpvHeapFile;
hHeapFile = HeapCreate(0x00040000, dwFileSize, 0);
if((DWORD)hHeapFile != STATUS_NO_MEMORY)
{
lpvHeapFile = HeapAlloc(hHeapFile, HEAP_ZERO_MEMORY, 0);
if(parseLogFile(hLogFile, lpvHeapFile, dwFileSize, dwRead)){
pSuccess = TRUE;
}
HeapDestroy(hHeapFile);
}
}
UnlockFile(hLogFile, 0, 0, dwRead, 0);
CloseHandle(hLogFile);
}
return pSuccess;
}
</code
My issue is that in the function definition GenerateStats outputting lszLogFile outputs the correct file path, so the value lszLogFile is pointing to is correct, however if I dereference the pointer, I get a value of c which is incorrect. c is what is passed onto the function CreateFile which is incorrect. I actually want the value that is referenced by lszLogFile to be passed onto that function.
I have tried multiple ways on passing on the pointed value with no success. I have tried to type-cast it in multiple ways such as: LPSTR, LPCSTR, const char* as well as changing the function parameter type of lszLogFile in the GenerateStats parameter list to different types. I have also tried copying the value of lszLogFile using lstrcpy() to another variable (as well as trying to static_cast the variables to various types) and it still does not work. Everytime I try to use lstrcpy() and I attempt to type cast say in the form of something like this:
LPSTR lpcsLogFile;
lstrcpy(lpcsLogFile, lszLogFile);
lstrcpy(lpcsLogFile, static_cast<const char*>(lszLogFile));
I receive unhandled exception errors (which I do understand why it happens but i've exausted all my know how in order to solve the problem!).
So if anyone can see where I am making my mistake, I would really appreciate any input.
Thanks!
Robbie
-- modified at 12:46 Tuesday 20th June, 2006
Made some grammatical changes!
|
|
|
|
|
Didn't look through the whole code since I see similar errors littered all over.
char* RegLocation = "";
:
lstrcpy(RegLocation, rspath);
You should ask yourself where RegLocation is pointing to, and how much memory is available at that location. You should also ask yourself if modifying a string literal makes sense.
Any reason why you are not using std::string or CString?
|
|
|
|
|
capricious_001 wrote: char rspath[255];
strcpy(rspath,"");
Use this instead:
char rspath[255] = {0}; capricious_001 wrote: lstrcat(rspath, "\\");
What if rspath already ends with a backslash? Use PathAddBackslash() instead.
Why mix strcpy() with lstrcpy() ?
capricious_001 wrote: LPSTR lpcsLogFile;
lstrcpy(lpcsLogFile, lszLogFile);
//or this
lstrcpy(lpcsLogFile, static_cast(lszLogFile));
This will not work since lpcsLogFile is a pointer that is not pointing to allocated memory.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks a lot guys, That worked.
This is the change I made.
<br />
<br />
char rspath[255] = {0};<br />
char* RegLocation = rspath;<br />
<br />
As well as removed lstrcat(rspath, "\\"); and replaced it with PathAddBackslash() . Even though that hkey value will most likely never have a backslash I put it in just in case. As well I will keep that function just in case I need it for the future so thank you for that David.
And yes strcpy() was actually lstrcpy() I just forgot the l.
btw what were the other errors that I made hfry? Just so it doesnt bites me in the ass when I'm done this module.
Thanks,
Robbie
-- modified at 14:11 Tuesday 20th June, 2006
|
|
|
|
|
Fixing RegLocation to point to some allocated memory would fix the problems. It was all the same type of error, basically when using strcpy / strcat etc you need to ensure that the destination buffer has enough memory to store the resultant string.
|
|
|
|
|
Yup I fixed that and everything is running more smoothly!
|
|
|
|
|
I have a C++ application that i am looking to provide a button that will have the functionality of hitting an ftp server and playing a video clip. I have some understanding of how to do this with ShellExecute in C++ if i have a clip on a web server but not sure about an ftp server. Cannot use ShellExecute for an ftp server can i?
Any ideas anyone?
|
|
|
|
|
depends
in this example, easiest now look at ftp clients relevant features
Kuphryn
|
|
|
|
|
|
LCI wrote: do this with ShellExecute in C++ if i have a clip on a web server
That is not an application it's a script. You could do that from a Javascript file. HTTP is a stateless protocol Ftp is a stateful protocol. I don't recommend trying to script a stateful protocol, but that's just me.
See if this[^] helps.
|
|
|
|
|
I am open to suggestions cause the fact is that i do not know how to do this. Whatever i use must be in C++, or if you know of a better way i will be open. Just need to be able to play a video clip on an ftp server from a C++ application.
|
|
|
|
|
The requirements you give are not specific enough to help you. It would be like asking an Architect to design you a Red House. He doesn't even know where to start. For example one way I could interpret your post would be to suggest that you write a C++ NT Service that would transfer the file from the FTP Server to the Web Server so that you could use your existing knowledge that you gave as follows:
LCI wrote: I have some understanding of how to do this with ShellExecute in C++ if i have a clip on a web server
But I have no way of knowing if this meets your requirements.
|
|
|
|
|
Unfortunately, these files are located on an ftp server alone. I am not able to put them on a web server. I have no C++ NT service. Just a C++ application that i am placing a button on that says, "play video". I will figure out how to associate the file name of the video clip that i need. All i need to know is how to access that video clip and have it play in a default player.
Now, the questions that i have are :
1. Is this possible given what i said.
2. If so, what api's etc. would i use.
Thanks again,
|
|
|
|
|
LCI wrote: Just a C++ application that i am placing a button on that says, "play video".
Strange requirements and stranger application, is it a school project?
A brute force method would be to transfer the file to the local machine then launch it in the default player.
There are Windows APIs called WinInet that provide FTP client functionality. MFC has Wrapper classes for the API like CFtpConnection, CFtpFindFile, etc. There is a CodeProject article that might help you Article[^]
good luck.
|
|
|
|
|
Say i have two network cards in my system . How do i programatically get the IP address of the the second network card ?
Engineering is the effort !
|
|
|
|
|
See if this article is of any help.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|