|
Maybe if I could get a pointer to CComboBox from CFileDialog , I can find more about this problem ... but I can not ... I tried this:
void CFileDialogExt::OnTypeChange()
{
CString sTemp;
CComboBox* pCombo = (CComboBox*)GetDlgItem(cmb1);
if(NULL != pCombo->GetSafeHwnd())
{
int nIndex = pCombo->GetCurSel();
if(CB_ERR != nIndex)
pCombo->GetLBText(nIndex, sTemp);
}
TRACE(">>>%s\n", sTemp);
switch(GetOFN().nFilterIndex)
{
case 1:
SetDefExt(_T("bmp"));
break;
case 2:
SetDefExt(_T("gif"));
break;
case 3:
SetDefExt(_T("jpg"));
break;
case 4:
SetDefExt(_T("png"));
break;
case 5:
SetDefExt(_T("tiff"));
break;
case 6:
SetDefExt(_T("dcm"));
break;
}
CFileDialog::OnTypeChange();
}
but pCombo seem to be null ...
|
|
|
|
|
We do something similar.
In the OnTypeChange virtual method:
We have a external list of extension (external to the file dialog)
We get the selected filter extension (m_ofn.nFilterIndex).
We get the current filename (GetFileName())
Extract the filename without extension and replace with the new extension
and call this :
SetControlText(edt1, fileNameNoExtension );
This will change the name of the file in the file dialog editbox.
Good luck.
I'd rather be phishing!
|
|
|
|
|
Yes, there is a solution, but the file dialog has an old style ...
|
|
|
|
|
Farmers want to be able to project business investment needs over a given period of time (in months). During
the program development, you consult a Rabbit specialist who gives you certain facts about rabbits as stated
below.
i) A female rabbit is called doe, a male rabbit is a buck and baby rabbits are kittens.
ii) Female rabbits take two months to mature and start mating. Once they start mating, they produce every
month. On average, a single rabbit produces 8 kittens every time they produce.
Assuming that the framers will only invest in female rabbits and that male rabbits will always be hired during matting
period and their number is negligible. Assume that no rabbit dies on the farm and that they will all grow at the same
rate.
Write a c program that prompts the farmer to input the initial number of rabbits on the farm and the number of
months the farmer wants to sustain the farm. The program should compute and print out the expected number of
rabbits on the farm for each month until the last month.
|
|
|
|
|
 Ive been able to write this but i feel it can be sized down and made better your direct ideas will be of much help as I am only abt 2weeks in c programming but hv been working very hard to learn
thks take a look
#include<stdio.h>
int main()
{
int initialrabbits,no_months,Kittens[10],Rabbits,count=1,kits,totalkittens;
printf("\nEnter initial no of rabbits:\a ");
scanf("%d",&initialrabbits);
printf("\nEnter number of months to be projected:\a ");
scanf("%d",&no_months);
for(count=1;count<=no_months;count++)
{
if (count==1){
Kittens[0]=initialrabbits*8;
Rabbits=initialrabbits;
kits=Kittens[0];
totalkittens=Kittens[0];}
else if (count==2){
Kittens[1]=initialrabbits*8;
Rabbits=initialrabbits;
kits=Kittens[1];
totalkittens=Kittens[0]+Kittens[1];}
else if (count==3){
Kittens[2]=(Kittens[0]+initialrabbits)*8;
Rabbits=Kittens[0]+initialrabbits;
kits=Kittens[2];
totalkittens=Kittens[1]+Kittens[2];}
else if (count==4){
Kittens[3]=(Kittens[0]+Kittens[1]+initialrabbits)*8;
Rabbits=Kittens[0]+Kittens[1]+initialrabbits;
kits=Kittens[3];
totalkittens=Kittens[2]+Kittens[3];}
else if (count==5){
Kittens[4]=(Kittens[0]+Kittens[1]+Kittens[2]+initialrabbits)*8;
Rabbits=Kittens[0]+Kittens[1]+Kittens[2]+initialrabbits;
kits=Kittens[4];
totalkittens=Kittens[3]+Kittens[4];}
else if (count==6){
Kittens[5]=(Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+initialrabbits)*8;
Rabbits=Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+initialrabbits;
kits=Kittens[5];
totalkittens=Kittens[4]+Kittens[5];}
else if (count==7){
Kittens[6]=(Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+initialrabbits)*8;
Rabbits=Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+initialrabbits;
kits=Kittens[6];
totalkittens=Kittens[5]+Kittens[6];}
else if (count==8){
Kittens[7]=(Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+Kittens[5]+initialrabbits)*8;
Rabbits=Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+Kittens[5]+initialrabbits;
kits=Kittens[7];
totalkittens=Kittens[6]+Kittens[7];}
else if (count==9){
Kittens[8]=(Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+Kittens[5]+Kittens[6]+initialrabbits)*8;
Rabbits=Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+Kittens[5]+Kittens[6]+initialrabbits;
kits=Kittens[8];
totalkittens=Kittens[7]+Kittens[8];}
else if (count==10){
Kittens[9]=(Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+Kittens[5]+Kittens[6]+Kittens[7]+initialrabbits)*8;
Rabbits=Kittens[0]+Kittens[1]+Kittens[2]+Kittens[3]+Kittens[4]+Kittens[5]+Kittens[6]+Kittens[7]+initialrabbits;
kits=Kittens[9];
totalkittens=Kittens[8]+Kittens[9];}
printf("\n\tMONTH %d",count);
printf("\nNUMBER OF RABBITS: %d",Rabbits);
printf("\nKittens produced this month: %d",kits);
printf("\nTotal kittens now: %d\n",totalkittens);
}
return 0;
}
|
|
|
|
|
No need to have all of the if /else conditions within the for() loop. Try something a bit leaner, like:
#include <stdio.h>
int main()
{
int initialrabbits,
no_months,
Kittens[10],
Rabbits,
kits,
totalkittens = 0;
printf("\nEnter initial no of rabbits:\a ");
scanf("%d",&initialrabbits);
printf("\nEnter number of months to be projected:\a ");
scanf("%d",&no_months);
for(int count=0;count<no_months;count++)
{
Kittens[count]=initialrabbits*8;
Rabbits=initialrabbits;
kits=Kittens[count];
totalkittens+=Kittens[count];
printf("\n\tMONTH %d",count);
printf("\nNUMBER OF RABBITS: %d",Rabbits);
printf("\nKittens produced this month: %d",kits);
printf("\nTotal kittens now: %d\n",totalkittens);
}
return 0;
}
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
See #11 here.
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Kittens are baby cats, kits are baby rabbits
Now, to your question, what have you accomplished so far in the program?
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
Paul Conrad wrote: ...kits are baby rabbits Either designation is correct.
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I intend to save CBitmap into a bmp file, here is the code:
CMyView* pView = (CMyView*)GetNextView(pos);
CDC* pDC = pView->GetDC();
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(pDC, GetTotalCx(), GetTotalCy());
CBitmap* pOldBitmap = (CBitmap*)MemDC.SelectObject(&bitmap);
pDC->BitBlt(0, 0, GetTotalCx(), GetTotalCy(), &MemDC, 0, 0, SRCCOPY);
CBitmap* pFinalBitmap = (CBitmap*)MemDC.SelectObject(pOldBitmap);
CImage Image;
Image.Attach((HBITMAP)pFinalBitmap->m_hObject);
Image.Save(ar.GetFile()->GetFileName(), Gdiplus::ImageFormatBMP);
bitmap.DeleteObject();
but the resulting bitmap file has 0 bytes ... why ? Could you help me ?
|
|
|
|
|
How are defined GetTotalCx, GetTotalCy ?
|
|
|
|
|
They have the bitmap sizes, and they have valid values: 1400X1000. (I verified that).
P.S. Moreover, if I put this code on OnDraw handler, is drawing well.
modified 29-Sep-15 6:17am.
|
|
|
|
|
Seem to go now, I overload CDocument::DoSave(LPCTSTR lpszPathName, BOOL bReplace) , and I put there the saving code ... In case that everyone need it. Thank you for all support.
|
|
|
|
|
I don't think that it is the source of your problem, but there is an error in your code:
You are deleting the CBitmap while it is still attached to the CImage . So you should detach first or use CImage::Destroy which will detach and delete the bitmap.
You should also check the return value of the Save function.
|
|
|
|
|
CDC* pDC = pView->GetDC();
int nSaveDC = pDC->SaveDC();
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(pDC, GetTotalCx(), GetTotalCy());
CBitmap* pOldBitmap = (CBitmap*)MemDC.SelectObject(&bitmap);
pDC->BitBlt(0, 0, GetTotalCx(), GetTotalCy(), &MemDC, 0, 0, SRCCOPY);
CBitmap* pFinalBitmap = (CBitmap*)MemDC.SelectObject(pOldBitmap);
CImage Image;
Image.Attach((HBITMAP)pFinalBitmap->m_hObject);
Image.Save(lpszPathName, Gdiplus::ImageFormatBMP);
Image.Detach();
pDC->RestoreDC(nSaveDC);
bitmap.DeleteObject();
Here is the new code ... but strange, CImage::Save return 0... it is OK ? The saved image looks good ...
|
|
|
|
|
CImage::Save returns a HRESULT where zero indicates success.
|
|
|
|
|
Ahh, yes, you are right. Thank you.
|
|
|
|
|
I want to drag and drop a file on treeview to a listbox.But i only drag item only on treeview but i can't drag outside treeview control.
Can't you help me ?
Many thanks
|
|
|
|
|
|
Linking executable ggpofba-ng.exe...
main.o : error LNK2001: símbolos externos indefinidos "void __cdecl QuarkInit(wchar_t *)" (?QuarkInit@@YAXPA_W@Z)
ggpofba-ng.exe : fatal error LNK1120: 1 externo não resolvidos
makefile.vc:313: recipe for target 'ggpofba-ng.exe' failed
mingw32-make[2]: *** [ggpofba-ng.exe] Error 1120
this error is happening at the end of compilation I already posted something about it helped me include everything right in .he cpp
I discovered that for this error does not appear I have to change in cpp put TCHAR more if I do more error appears in the .cpp then he is char how do I corrigiri so I will let the three files containing this function I grasped C ++ now vlw
|
|
|
|
|
part of the main.cpp
else if (_tcsncmp(szName, _T("quark:"), 6) == 0) {
QuarkInit(szName);
|
|
|
|
|
part of the .h
// fba_quark.cpp
bool QuarkInit(CHAR *connect);
bool QuarkNetworkGame();
bool QuarkDumpSprites();
|
|
|
|
|
Reset your application properties to use ASCII rather than Unicode, or find a matching Unicode library for the Quark functions.
|
|
|
|
|
Go to Parentwhen they procure step QuarkInit ( TCHAR * connect) he did not correct me back the main error plus it returns these errors in my function and do not know how to fix
excuse the English BR
error C2664: 'int printf(const char *,...)': não é possível converter um argumento 1 de 'TCHAR *' em 'const char *'
Tipos apontados não são relacionados; conversão requer reinterpret_cast, conversão C-style ou conversão function-style
if I send to you the code is how you correct for me the code and an online game emulator
|
|
|
|
|
robsons2007 wrote: if I send to you the code No, my support is confined to answering questions here. The problem is that you are mixing ASCII and non-ASCII constants and variables within your code, and confusing both the compiler and the linker. Take a look at What are TCHAR, WCHAR, LPSTR, LPWSTR, LPCTSTR (etc.)?[^].
|
|
|
|