|
Hi,
I have created Static control programmatically.I need to display image in
static control of Dialog.I have written following code
HINSTANCE hInstTemp = AfxGetApp()->m_hInstance;
HBITMAP hbmp = NULL;
if(hInstTemp != NULL)
hbmp = (HBITMAP)LoadImage(hInstTemp,_T("C:\\vicky.bmp"), IMAGE_BITMAP, 50, 50,LR_LOADFROMFILE);
if(hbmp != NULL)
myStatic->SetBitmap(hbmp);
shall I need to call DrawItem or override DrawItem??
|
|
|
|
|
Have you set the SS_BITMAP for that static control?
- ns ami -
|
|
|
|
|
yes I have set SS_BITMAP|SS_CENTER.
If I did not set SS_CENTER Image is coming properly.
Thanks for your reply.
|
|
|
|
|
hemlat wrote: yes I have set SS_BITMAP|SS_CENTER.
I doubt you mistook SS_CENTER instead of SS_CENTERIMAGE. Please check.
- ns ami -
|
|
|
|
|
No you can insert SS_BITMAP with ModifyStyle to your control and for bmp files you can use of this function but for jpg files you need to use of CImage class.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Thanks for your reply.JPG files also coming Properly.
|
|
|
|
|
Assume prfimg Bitmap is proper.
EncoderParameters pEncoderParameters;
pEncoderParameters.Count = 1;
pEncoderParameters.Parameter[0].Guid = EncoderCompression;
pEncoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
pEncoderParameters.Parameter[0].NumberOfValues = 1;
ULONG compression = EncoderValueCompressionRle;
pEncoderParameters.Parameter[0].Value = &compression;
GetEncoderClsid(L"image/tiff", &encoderClsid);
st = prfimg->Save(L"i:\\m\\img.tif", &encoderClsid, &pEncoderParameters);
getting value of st as InvalidParameter and the image is not saved properly on disk(saved image size on disk is 1KB)
Please tell if something more needs to be done to save tif image with Rle compression.
Other compression options gives the same InvalidParameter result.
Thanks and Regards.
|
|
|
|
|
I have added the key in HKLM on Xp64bit OS.
HKEY_LOCAL_MACHINESOFTWARE\\TEST\\App\\MyKey === "CodeProject"
Now, I have tried with below mentioned way,
bool Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\TEST\\App"), 0, KEY_READ, &hKey) == ERROR_SUCCESS;
if (Result)
{
Result = RegQueryValueEx(hKey, TEXT("MyKey"), NULL, &dwType, (LPBYTE)&szTemp, &dwSize) == ERROR_SUCCESS;
switch(dwType)
{
case REG_BINARY:
AfxMessageBox ("\ntype: REG_BINARY");
break;
case REG_NONE:
AfxMessageBox ("\ntype: REG_NONE");
break;
}
}
Messagebox displays"type: REG_NONE". That means, "No defined value type".
So, how to get my key (MyKey) value "CodeProject"?
Sethuraman.K
|
|
|
|
|
Sethuraman.K wrote: if (Result)
This must be if (ERROR_SUCCESS == Result)
and Result must be declared as a LONG and not bool .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
That works fine only. I am talking about "dwType"
Sethuraman.K
|
|
|
|
|
The value of ERROR_SUCCESS is 0.
So, in you code if it is entering if(Result) , it means you are not getting ERROR_SUCCESS , which means an error in the open itself.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I got the solution. If our application is 32bit then registry entry (only for HKEY_LOCAL_MACHINE) in 64 bit OS sould be in
HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node
in my case entry should be in
HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Test\\App
Sethuraman.K
|
|
|
|
|
Hi All
I am useing timer in main dialog class.Calling Timer on On OnInitDialog function.But my dilaog become not responding.Plz help me.
|
|
|
|
|
It is most likely because you did something wrong.
...
but seriously, give some code, more details, otherwise noone will be able to help you.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
How are you 'Calling Timer' (you know, no code => no help... )?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
void CTimer::OnTimer(UINT_PTR nIDEvent)
{
OnBnClickeTimer();
CDialog::OnTimer(nIDEvent);
}
void CTimer::OnStartTimer()
{
SetTimer(2,10000, 0);
}
void CTimer::OnStopTimer()
{
KillTimer (0);
}
BOOL CTimer::OnInitDialog()
{
OnBnClickeTimer();
}
void CTimer::OnBnClickedTimer()
{
check:
for(;aq<10)
{
finalString=a1[aq];
char * szMyString = (char *)(LPCTSTR)finalString;
CString string = _T(szMyString);
CString DirPath;
CString string1=string;
string1 +='\0';
int nLen = string1.GetLength();
LPCSTR lpszBuf = string1.GetBuffer(nLen);
string1.ReleaseBuffer();
LPCSTR pF=lpszBuf;
LPCSTR pT="c:\\Backup";
if (!fo.Copy(pF,pT));
aq++;
}
OnStopTimer();
}
CString a1[aq] is external vaiable.
Plz help me
modified on Tuesday, February 24, 2009 6:43 AM
|
|
|
|
|
- Please check the posted code (for instance use
< to escape the symbol < when required). - Why are you calling directly the timer function inside
OnInitDialog (instead of starting the timer? You may actually do it, but usually you haven't...)? - Since you're calling directly (form
OnInitDialog ) your timer function (OnBnClickedTimer ) it doesn't make sense the OnStopTimer call in the latter.
Anyway your application 'freezes' possibly because of a bug in your loop. You should debug it in order to have a clue about (ispecting your code is also difficult because of the, already mentioned, bad formatting).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Also i think he is not passing correct id to KillTimer..
Regards,
Sandip.
|
|
|
|
|
Yes, you are right, of course.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Timers tutorial[^] is for you.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I want to open all files with a certain name and/or a certain type, but for that I need to know the contents of a directory first.
How do I see them?
Thanks.
|
|
|
|
|
FindFirstFile and FindNextFile should do it.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
|
Thanks.
I got something (I think) with FindFirstFile and FindNextFile .
Though, it doesn't quite work, this whole code is in a try catch block, but still throws a System.AccessViolationException (which is .NET specific and I can't use it or acces it) and does nothing:
try
{
fstream file;
vector<lpwin32_find_dataw> files;
LPCTSTR namepointer;
HANDLE handle;
string line = "";
int i = 0;
int size;
char directory [] = "C:\\Folder";
char *stringpointer = directory ;
files.assign(1, LPWIN32_FIND_DATAW());
handle = FindFirstFile(namepointer, files[i]);
while (handle != INVALID_HANDLE_VALUE)
{
FindNextFile(handle, files[i]);
files.assign(1, LPWIN32_FIND_DATAW());
i++;
}
size = files.size();
cout << files.size() << endl;
for (int k = 0; k < size; k++)
{
cout << "Reading File:" << files[k]->cFileName << endl;
}
getchar();
return 0;
}
catch (exception ex)
{
cout << "An error has occurred." << endl;
cout << ex.what() << endl;
}</lpwin32_find_dataw> I want to read the filenames to check if they're txt files with the right kind of name and then read from them to process the text of each.
Thanks.
|
|
|
|
|
Megidolaon wrote: ...but still throws a System.AccessViolationException...
Where/when?
Why do you have a vector of WIN32_FIND_DATA structures? One is sufficient.
Megidolaon wrote: handle = FindFirstFile(namepointer, files[i]);
What is the value of namepointer ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|