Click here to Skip to main content
15,908,115 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So, I'm currently writing a simple application for a friend, just to demonstrate cryptography and explain how encryption works on everyday computers.

However, I've ran into an problem; When I try and call the form that decrypts the data, it shows up blank.

What I have tried:

So, I've tried using the .show() method that I used on all of my other forms, but now the form comes up blank.

Below is the code that I have tried to use:

First Form - I would click a button to call the decryption form/window:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Media;

namespace CryptExample
{

    //Form 1

    public partial class cryptMsg : Form
    {
        public cryptMsg()
        {
            InitializeComponent();
        }

        private void pictureBox3_Click(object sender, EventArgs e)
        {
            cryptUnlock showDecrypt = new cryptUnlock();
            showDecrypt.Show();
        }

        private void label2_Click(object sender, EventArgs e)
        {
            cryptUnlock showDecrypt = new cryptUnlock();
            showDecrypt.Show();
        }
    }
}


Second Form - The decryption window

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Security;
using System.Security.Cryptography;
using System.IO;
using System.Net;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;

namespace CryptExample
{
	//Form 2
	
    public partial class cryptUnlock : Form
    {
    	public cryptUnlock()
        {
            InitializeComponent();
            //Add in decryption stuff later
        }
    }
}
Posted
Updated 23-Nov-16 7:19am
v2
Comments
[no name] 23-Nov-16 10:25am    
Okay... and? Maybe there is nothing to show? Not sure what you think we can tell you. You know, not being able to see your code and all.
Member 12866713 23-Nov-16 10:35am    
Added in the code, as per request.
[no name] 23-Nov-16 10:40am    
Okay considering that your cryptUnlock form doesn't do anything, it should not be a surprise that the form is empty.
Member 12866713 23-Nov-16 10:50am    
CryptUnlock has been designed (visually), the issue is that when I run the application, the form that is supposed to appear (CryptUnlock) does not and instead a blank form appears (similar to this, but has no text title: http://3.bp.blogspot.com/-Kgd5lik-Txk/UfHsJ_fEEPI/AAAAAAAAAD0/Zmk7OO1ytaY/s1600/05.png ).

Sorry if I didn't make this clear enough at the start of the thread.
Member 12866713 23-Nov-16 11:21am    
The form is not supposed to do anything (just yet), as I am still writing the decryption functionality. Just to make it more clear; I have already designed the form layout (graphically).

The problem is that when I attempt to call my graphically designed form (CryptUnlock), the application just shows a 'blank form' (similar to this, but the blank form has no text title: http://3.bp.blogspot.com/-Kgd5lik-Txk/UfHsJ_fEEPI/AAAAAAAAAD0/Zmk7OO1ytaY/s1600/05.png ).

Start by looking at your form in the designer: does it have any controls on it? Does it compile clean, with no errors and no warnings?
If it does, then put a breakpoint on the first line of both of those methods, and run your app in the debugger. When it hits the breakpoint, step into the constructor and make sure that the designer generated code is creating the controls and adding them to your form.
If everything looks right and you get no exceptions, or other errors, then you need to explain exactly what you mean by "shows up blank" - if the controls are added correctly, the form will not be truly blank.
 
Share this answer
 
Comments
Member 12866713 23-Nov-16 10:45am    
Hi OriginalGriff,

It has compiled and ran without any warnings or errors within the console. What I meant by "shows up blank", is that the form appears with all the controls (similar to this, apart from the form has no text title: http://3.bp.blogspot.com/-Kgd5lik-Txk/UfHsJ_fEEPI/AAAAAAAAAD0/Zmk7OO1ytaY/s1600/05.png ), but it is not the form that I created within the designer.
Member 12866713 23-Nov-16 11:12am    
Hi OriginalGriff,

It has compiled and ran without any warnings or errors within the console. What I meant by "shows up blank", is that the form appears with all the controls (similar to this: http://3.bp.blogspot.com/-Kgd5lik-Txk/UfHsJ_fEEPI/AAAAAAAAAD0/Zmk7OO1ytaY/s1600/05.png ), but it is not the form that I created within the designer.
OriginalGriff 23-Nov-16 11:20am    
OK, so it's not a "blank form" at all - except the .PNG file shows ... a blank form with no controls!
In what way is it "Not the form you created in the designer"?
What happened when you used the debugger?
Remember - I can't see what you did design, so I have no idea what it shoudl look like.
Member 12866713 23-Nov-16 11:28am    
Hi OriginalGriff,

This is how the form (cryptUnlock) is supposed to look like: http://i.imgur.com/c7AXsQL.png

However, when I attempt to call the form it looks something similar to this: http://3.bp.blogspot.com/-Kgd5lik-Txk/UfHsJ_fEEPI/AAAAAAAAAD0/Zmk7OO1ytaY/s1600/05.png
OriginalGriff 23-Nov-16 11:59am    
Well, the second one does look like a blank, default form, without any changes. So ... what happened when you ran the debugger? What controls did it add in the designer generated code when you stepped though at run time?

Are you absolutely sure you are looking at the right form, and that it complied without problems? Because if it doesn't compile, then when you run it you could be looking at an older, unmodified version of the form. Check it: add a line of code to the form constructor, and make sure it is executed in teh debugger.
Try ShowDialog() instead.

Using Show() makes it a modeless form, and it's probably behind your main form.
 
Share this answer
 
Comments
Member 12866713 23-Nov-16 10:41am    
Hi John,

Tried this, but the same issue occurs (blank form).
I forgot to add the following code to my decryption form (CryptUnlock);

C#
public cryptUnlock()
        {
            InitializeComponent();
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900