|
You can still use the ParseDateTime, but you need to set the format first.
Here's what I've done...
First, get the current format using
GetLocaleInfo(m_LCID, LOCALE_SSHORTDATE, m_csOriginalSDateFormat.GetBuffer(MAX_PATH + 1), MAX_PATH);
m_csOriginalSDateFormat.ReleaseBuffer();
(m_csOriginalSDateFormat is a CString)
Next have your own CString with the desired format:
m_csNewSDateFormat = _T("M/d/yyyy");
Now, set the desired format, parse the date/time, and restore the original format:
SetLocaleInfo(m_LCID, LOCALE_SSHORTDATE, m_csNewSDateFormat);
oleStartTime.ParseDateTime(csDateTime);
SetLocaleInfo(m_LCID, LOCALE_SSHORTDATE, m_csOriginalSDateFormat);
Hope this helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
|
|
Thanks again... but this is to return a string with a format...
What I wanted is to parse a string into a date with a format!
Something like
COleDatetime t;
t.IsThisStringADateWithThisFormat(_T("10012012"),"ddMMyyyy");
But I have managed (see my post above)!
Thanks anyway!
Jerry
|
|
|
|
|
hi,
i have developed program where two separate windows, one containing Map and other the dialog form with some controls, are opened. the program is when i click on Map window, its coordinates are displayed in the static text on the dialog form window. what i want is that when i click on Map window (which is at the front at the time of clicking) the dialog form window should appear at the front showing the results of my click, i.e the coordinates.
Regards
Jawad
modified 18-Jul-12 4:00am.
|
|
|
|
|
When you click on the map you can set the dialog's property to WS_EX_TOPMOST as described here[^]. You would then need to reset that value on some other action. Alternatively you could use the SetWindowPos() [^] function to alter its place in the Z-order, i.e. bring it to the front.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
thank you Richard MacCutchan.
|
|
|
|
|
in my app, I use ftp raw commands to upload several files to server,
after sending PASV and STOR from command port, file transfer starts on data port - so far so good.
But, when I send same commands to server again to upload second file before first uploading completed , server answers "unknowing command" - to second PASV and STOR.
So, I have to wait for first uploading completed to upload second file.
Any comments as solution?
Anything wrong in my ftp commands or process?
how to upload 2 or more files at same time?
how to open multiple data sockets (ports) with one command socket (port)?
Thanks.
.
|
|
|
|
|
Just a guess, but wouldn't you need to create a second connection to the server to upload the second file simultaneously?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
The number of simultaneous transfers is under control of the server. When you send PASV, it will respond with none, one or more lines indicating a data port on which it is listening. If you can't work it out from reading manuals (RFC959 is a good start), find a real server that works, and get Wireshark on the job to see what messages go back and forth. (A good server like Filezilla maintains a log so you probably don't need Wireshark, but it'll be useful when you come to debugging your own code.)
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
hi
am looking to move the existing file along with progress control update .
i tried with movefilewithprogrees did not work .
canany body explain the concept
movefilewithprogrees how it work or any alternate way for moving the file with progress update .
this movefilewithprogress will move the file if i get how much this function will transfer the data .
Best
Regards
sarfaraz
|
|
|
|
|
Can you please post your code snipet?
For your conceptual study, you can have a look at this[^].
|
|
|
|
|
sarfaraznawaz wrote: i tried with movefilewithprogrees did not work . You need to explain what it was that did not work, we cannot guess. Have you checked the documentation[^] to ensure that your function call is correct and also checked for any error responses?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
sarfaraznawaz wrote: i tried with movefilewithprogrees did not work . Which is all but totally meaningless without showing how you are using that function, and what GetLastError() is returning. We're not mind readers!
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
see i tried like this but it does not coming in callback function .
so that i use while loop to update the progress
<pre>DWORD CALLBACK CopyProgressRoutine(LARGE_INTEGER TotalFileSize,LARGE_INTEGER TotalBytesTransferred,LARGE_INTEGER StreamSize,
LARGE_INTEGER StreamBytesTransferred,DWORD dwStreamNumber,DWORD dwCallbackReason,
HANDLE hStoreFile,HANDLE hFinalFile,LPVOID lpData)
{
Temp_TotalBytesTransferred.QuadPart = TotalBytesTransferred.QuadPart;
Temp_TotalFileSize.QuadPart=TotalFileSize.QuadPart;
iNewPercent1 = int(( double(TotalBytesTransferred.QuadPart) /
double(TotalFileSize.QuadPart) ) * 100);
return PROGRESS_CONTINUE;
}</pre><pre lang="cs">while(savingbytetraversed<=m_li64FileSize.QuadPart)
{
::SendMessage(h_wnd,WM_APP + 12, 0,0);
savingbytetraversed+=10;
ullBytesTraversed = savingbytetraversed;
if (bSaveexecution == 0)
{
successForsavingfile == FALSE;
break;
}
}
if (savingbytetraversed >= m_li64FileSize.QuadPart )
{
successForsavingfile =TRUE;
::SendMessage(h_wnd,WM_APP + 12, 0,0);
MoveFileWithProgress(FilePathForSaving,pathforsaving,
CopyProgressRoutine, NULL, MOVEFILE_COPY_ALLOWED);
::MessageBox(h_wnd,_T("File Saved successfully "),_T("Information "),MB_ICONINFORMATION);
successForsavingfile = FALSE;
closefile= FALSE;
}</pre>
|
|
|
|
|
You're calling MoveFileWithProgress() from within the callback function?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
shot.h
#ifndef CTGALOADER_H
#define CTGALOADER_H
class CTGALoader
{
public:
CTGALoader(); ~CTGALoader();
bool LoadTGAFile(char *filename); void SaveTGAScreenShot(char *filename,
int width,
int height); void FreeImage();
unsigned int ID; int imageWidth; int imageHeight;
protected:
void GenerateTexture(); bool LoadTGA(char *filename); bool WriteTGA(char *file, short int width,
short int height,
unsigned char *image);
unsigned char *image; bool textureExist; int type; };
#endif
shot.cpp
#include"shot.h"
#include <windows.h>
#include <./gl/GL.H>
#include <./gl/GLU.H>
#include <STDIO.H>
#pragma comment(lib,"OPENGL32.LIB")
#pragma comment(lib,"Glu32.lib")
CTGALoader::CTGALoader()
{
image = 0;
textureExist = false;
type = 0;
}
CTGALoader::~CTGALoader()
{
FreeImage(); }
bool CTGALoader::LoadTGAFile(char *file)
{
if(textureExist)
FreeImage();
if(!LoadTGA(file))
return false;
if(image == 0)
{
return false;
}
GenerateTexture();
textureExist = true;
return true;
}
void CTGALoader::GenerateTexture()
{
glGenTextures(1, &ID);
glBindTexture(GL_TEXTURE_2D, ID);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
gluBuild2DMipmaps(GL_TEXTURE_2D, type, imageWidth, imageHeight,
type, GL_UNSIGNED_BYTE, image);
glTexImage2D(GL_TEXTURE_2D, 0, type, imageWidth, imageHeight,
0, type, GL_UNSIGNED_BYTE, image);
}
bool CTGALoader::LoadTGA(char* file)
{
FILE *pfile;
unsigned char tempColor; unsigned char uselessChar; short int uselessInt; int colorMode; long tgaSize; long index; unsigned char imageTypeCode;
unsigned char bitCount;
pfile = fopen(file, "rb");
if (!pfile)
return false;
fread(&uselessChar, sizeof(unsigned char), 1, pfile);
fread(&uselessChar, sizeof(unsigned char), 1, pfile);
fread(&imageTypeCode, sizeof(unsigned char), 1, pfile);
if ((imageTypeCode != 2) && (imageTypeCode != 3))
{
fclose(pfile);
return false;
}
fread(&uselessInt, sizeof(short int), 1, pfile);
fread(&uselessInt, sizeof(short int), 1, pfile);
fread(&uselessChar, sizeof(unsigned char), 1, pfile);
fread(&uselessInt, sizeof(short int), 1, pfile);
fread(&uselessInt, sizeof(short int), 1, pfile);
fread(&imageWidth, sizeof(short int), 1, pfile);
fread(&imageHeight, sizeof(short int), 1, pfile);
fread(&bitCount, sizeof(unsigned char), 1, pfile);
fread(&uselessChar, sizeof(unsigned char), 1, pfile);
colorMode = bitCount / 8;
tgaSize = imageWidth * imageHeight * colorMode;
image = (unsigned char*)malloc(sizeof(unsigned char)*tgaSize);
fread(image, sizeof(unsigned char), tgaSize, pfile);
for (index = 0; index < tgaSize; index += colorMode)
{
tempColor = image[index];
image[index] = image[index + 2];
image[index + 2] = tempColor;
}
fclose(pfile);
if(bitCount == 32)
type = GL_RGBA;
else
type = GL_RGB;
return true;
}
void CTGALoader::FreeImage()
{
if(image)
{
free(image);
image = 0;
textureExist = false;
type = 0;
}
}
bool CTGALoader::WriteTGA(char *file, short int width, short int height, unsigned char *outImage)
{
FILE *pFile; unsigned char uselessChar; short int uselessInt; unsigned char imageType; int index; unsigned char bits; long Size; int colorMode;
unsigned char tempColors;
pFile = fopen(file, "wb");
if(!pFile) { fclose(pFile); return false; }
imageType = 2; colorMode = 3; bits = 24;
uselessChar = 0; uselessInt = 0;
fwrite(&uselessChar, sizeof(unsigned char), 1, pFile);
fwrite(&uselessChar, sizeof(unsigned char), 1, pFile);
fwrite(&imageType, sizeof(unsigned char), 1, pFile);
fwrite(&uselessInt, sizeof(short int), 1, pFile);
fwrite(&uselessInt, sizeof(short int), 1, pFile);
fwrite(&uselessChar, sizeof(unsigned char), 1, pFile);
fwrite(&uselessInt, sizeof(short int), 1, pFile);
fwrite(&uselessInt, sizeof(short int), 1, pFile);
fwrite(&width, sizeof(short int), 1, pFile);
fwrite(&height, sizeof(short int), 1, pFile);
fwrite(&bits, sizeof(unsigned char), 1, pFile);
fwrite(&uselessChar, sizeof(unsigned char), 1, pFile);
Size = width * height * colorMode;
for(index = 0; index < Size; index += colorMode)
{
tempColors = outImage[index];
outImage[index] = outImage[index + 2];
outImage[index + 2] = tempColors;
}
fwrite(outImage, sizeof(unsigned char), Size, pFile);
fclose(pFile);
return true;
}
void CTGALoader::SaveTGAScreenShot(char *filename, int w, int h)
{
unsigned char *outputImage = 0;
outputImage = (unsigned char*)malloc(w * h * 3);
memset(outputImage, 0, w * h * 3);
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, outputImage);
WriteTGA(filename, w, h, (unsigned char*)outputImage);
free(outputImage);
}
main.cpp
#include <windows.h>
#include "shot.h"
void main()
{
CTGALoader tga;
tga.SaveTGAScreenShot("123.TGA",1024,768);
}
the tga is whole black, why is it ?
thanks for your reply !
|
|
|
|
|
Far too much code here and far too few details. Try and narrow the problem down to a specific area of code and explain what is not working.
|
|
|
|
|
You have to draw some graphics first.
|
|
|
|
|
Two questions:
Selecting “No scroll” ( vertical) removes the header – feature or bug?
Is there a way to show / hide just the Report? Right now both header and report are controlled by ShowWindow.
I did look at GetSelectedCount but the sub-items updates are controlled by CRecordset DoFieldExchange so I guess it would not work.
I do appreciate your time and any to the point comments, however, please refrain from any “update to X "suggestions. Not an option for retired hobbyist.
Cheers Vaclav
|
|
|
|
|
Is the header removed only when changing the scroll flag with the resource editor or always even when changing the flag by code? In the first case it seems to be a bug of VC 6. You can then handle it by using SetExtendedStyle() when initializing the list control.
To hide the list content but not the header you may resize the window to the height of the header (plus height of horizontal scrollbar if present).
|
|
|
|
|
My code is still in rough development stage and I do erase the entire record each time I am adding a new one - hence the scrol bar is always moving.
I will eventually do just add new record and that should clear things a little. I thing part of the "problem" is that the recorset is always sorted in descending order after each new add.(maybe I can add in front of recordset instead of in the end of it!)
This is no big deal in real application, I was just messing with how last I can update few views. And since I have three of them with CListCtrl the update redraws are very visible.
I'll try to adjust the report size exluding the header.
|
|
|
|
|
To avoid redrawing (flickering) while the list is changed, disable redraw using SetRedraw(0) and re-enable it after the changings has been applied.
|
|
|
|
|
Thanks Jochen,
SetRedraw solved the "problem". No more header redraw and the vertical slider stays put.
|
|
|
|
|
I'm trying to understand how the CMFCToolbar works when adding controls in it, in particular adding a CMFCToolBarComboBoxButton .
I can create the toobar and add the combo box button (in the handler of AFX_WM_RESETTOOLBAR) and add the message to handle it :
ON_COMMAND(ID_COMBOBOX, OnComboBox)
ON_CBN_SELENDOK(ID_COMBOBOX, OnComboBox)
In that case the messages are handled in the document class.
Now, I'd like to be able to handle the message in the toolbar class (to have less clutter in the document or main frame classes).
So, I create a new toolbar class derived from CMFCToolbar (still able to add the combobox and handle the message if in the document class)
Now, I'm not certain what message I need to handle, seems I tried everyone of them (I've read TN062 on msdn).
I tried enabling the reflection on the toolbar :
m_myToolbar.EnableReflections(TRUE);
documentation for the above says : "Call this method to enable command reflection for toolbar buttons that contain embedded controls, such as combo boxes."
I've also tried to use the method CMFCToolbar::SetRouteCommandsViaFrame, but it does not seems to do anything interesting.
googling and binging does not return useful hits.
Anyone able to use that as expected ? or am I completely clueless and I'm not reading/understanding the documentation ?
Thanks
Max.
Watched code never compiles.
|
|
|
|
|